What I need done is simple... but its 3am and Im probably overlooking the obvious.
Im coding a simple forum. One table stores the forum titles, descriptions, etc, while the other stores the posts. In the forum listing, that shows the list of all forums, I want to grab the latest post in each forum, and display the post subject, poster and post ID, and date. Simple.
The only problem is, when I join to the posts table, it joins to the first record in the table, not the last, which would denote the last post in that forum.
Here is the simplified query that gets a list of forums + data for the "latest" post (which now functions as "first post").
SELECT forum_title, forum_id, post_subject, post_user, post_id, post_date FROM board_forums
LEFT JOIN board_posts
ON (forum_id = post_parentforum AND post_parentpost = 0)
WHERE forum_status = 1
GROUP BY forum_id
ORDER BY forum_position
How can I fix this?