1 up | 2 up | 3 up | 4 up |
^^^ Additional posts ^^^
zorg.ch
#53730 by @ 20.10.2004 20:33, edited @ 21.10.2004 11:18 - nach oben -
Die isch so:

(wennd verbesserige gsehsch bitte meldä)

SELECT

c.board, c.id, c.parent_id, c.text last_post_text,
UNIX_TIMESTAMP(c.date) last_post_date,
lu.id lu_id, lu.clan_tag lu_clan_tag, lu.username lu_username,

t.thread_id,
tu.id tu_id, tu.clan_tag tu_clan_tag, tu.username tu_username,
UNIX_TIMESTAMP(t.date) thread_date

, IF(ISNULL(tfav.thread_id ), 0, 1) AS isfavorite

, count(DISTINCT cnum.id) numposts

FROM comments_threads ct

LEFT JOIN comments c ON ( c.id = (
SELECT MAX( id )
FROM comments
WHERE thread_id = ct.thread_id AND board = ct.board) )
LEFT JOIN comments t ON (t.id = ct.comment_id)
LEFT JOIN comments cnum ON (ct.board = cnum.board AND ct.thread_id = cnum.thread_id)
LEFT JOIN templates s ON s.id = c.thread_id
LEFT JOIN bugtracker_bugs b ON b.id=c.thread_id
LEFT JOIN `events` e ON e.id=c.thread_id

LEFT JOIN user lu ON lu.id=c.user_id
LEFT JOIN user tu ON tu.id=t.user_id
LEFT JOIN comments_threads_rights ctr
ON (ctr.thread_id=ct.thread_id AND ctr.board=ct.board AND ctr.user_id='3')
LEFT JOIN comments_threads_favorites tfav
ON (tfav.board = ct.board AND tfav.thread_id = ct.thread_id AND tfav.user_id = '3')

WHERE
c.board IN ('b','f','h,'i','g')
AND (2 >= ct.rights OR ct.rights=3 AND ctr.user_id IS NOT NULL)
AND ct.comment_id IS NOT NULL

GROUP BY ct.thread_id

ORDER BY last_post_date DESC

LIMIT 0,23