Код: Выделить всё
$sql = 'SELECT p.post_id, t.topic_id, t.topic_title, t.topic_replies, t.forum_id, p.post_subject, p.post_text, p.post_time, p.bbcode_bitfield, p.bbcode_uid, u.username, u.user_id, u.user_colour
FROM ' . TOPICS_TABLE . ' t
INNER JOIN ' . POSTS_TABLE . ' p ON (t.topic_id = p.topic_id)
INNER JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)
WHERE t.topic_approved = 1
AND p.post_approved = 1
AND ' . $db->sql_in_set('p.forum_id', $forum_id_ary) . '
AND p.post_id = t.topic_first_post_id
ORDER BY p.post_time ASC'; 

