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