it "works" most likely because there is a very very high probability that no two posts have the same time
you should really still join based on the forum and active code as well...
Code:
SELECT topics.title
, topics.tid AS `id`
, forums.name AS `forum_name`
, forums.fid AS `forum_id`
, forums.view_level
, lp.latest_post
, lpo.author AS `latest_poster_id`
, users_b.email AS `last_poster_email`
, users_b.name AS `last_poster_name`
, users_b.uid AS `last_poster_uid`
, users_b.profile_url AS `last_poster_profile`
, user_groups.prefix
, user_groups.suffix
FROM forum_forums AS forums
INNER
JOIN forum_topics AS topics
ON topics.fid = forums.fid
INNER
JOIN ( SELECT tid
, MAX(time) AS latest_post
FROM forum_posts
WHERE `active` = 1
GROUP
BY tid ) AS lp
ON lp.tid = topics.tid
INNER
JOIN forum_posts AS lpo
ON lpo.tid = topics.tid
AND lpo.`active` = 1
AND lpo.time = lp.latest_post
INNER
JOIN users AS users_b
ON users_b.uid = lpo.author
INNER
JOIN user_groups
ON user_groups.id = users_b.user_group_id
WHERE forums.view_level <= '{$user_level}'
ORDER
BY lp.latest_post DESC
Bookmarks