Code: Alles auswählen
SELECT ... FROM ..., (SELECT * FROM phpbb_att_links ORDER BY attach_id DESC) AS al
Code: Alles auswählen
SELECT ... FROM ..., (SELECT * FROM phpbb_att_links ORDER BY attach_id DESC) AS al
Code: Alles auswählen
WHERE al.attach_id = al2.attach_id
Jo das klingt nach viel, aber andererseits..mgutt hat geschrieben:Das wird bei 50.000 Attachments etwas schwierig
Code: Alles auswählen
SELECT f.forum_id, f.forum_name, COUNT(al.attach_id) count, ad.attach_id, ad.physical_filename, ad.real_filename, ad.extension, ad.filetime, ad.thumbnail
FROM phpbb_topics t, phpbb_forums f, phpbb_posts p, (SELECT attach_id, post_id FROM phpbb_att_links ORDER BY attach_id DESC) al, phpbb_att_desc ad
WHERE t.topic_id = p.topic_id
AND p.post_id = al.post_id
AND al.attach_id = ad.attach_id
AND t.forum_id = f.forum_id
AND t.topic_sub_type = 12
AND t.forum_id IN(1, 2)
GROUP BY f.forum_id
ORDER BY f.forum_name ASC
Code: Alles auswählen
SELECT f.forum_id, f.forum_name, COUNT(al.attach_id) AS count, ad.*
FROM phpbb_topics t, phpbb_forums f, phpbb_posts p, phpbb_att_links al, phpbb_att_desc ad
WHERE t.topic_id = p.topic_id
AND p.post_id = al.post_id
AND ad.attach_id =
(
SELECT MAX(al2.attach_id)
FROM phpbb_att_links al2
)
AND t.forum_id = f.forum_id
AND t.topic_sub_type = 12
AND t.forum_id IN(1, 2)
GROUP BY f.forum_id
ORDER BY f.forum_name ASC
Code: Alles auswählen
SELECT f.forum_id, f.forum_name, COUNT(al.attach_id) count, ad.attach_id, ad.physical_filename, ad.real_filename, ad.extension, ad.filetime, ad.thumbnail
FROM phpbb_topics t, phpbb_forums f, phpbb_posts p, (SELECT attach_id, post_id FROM phpbb_att_links ORDER BY attach_id DESC LIMIT 3000) al, phpbb_att_desc ad
WHERE t.topic_id = p.topic_id
AND p.post_id = al.post_id
AND al.attach_id = ad.attach_id
AND t.forum_id = f.forum_id
AND t.topic_sub_type = 12
AND t.forum_id IN(1, 2)
GROUP BY f.forum_id
ORDER BY f.forum_name ASC
Das ginge wohl nur durch Trial&Error.mgutt hat geschrieben:Jetzt ist die Frage natürlich offen, wie man ein korrektes Limit auf den Wert genau ermitteln müsste, um die Abfrage dynamischer zu machen