I'm working with the PHPBB databases to pull some custom data. If you're familiar with the application I'd like to pull a few records and display them like the viewforum.php page does.
Basically it pulls the topic name, author, views, replies, last post datetime and last post username.
The three tables in my SQL statement are phpbb_posts, phpbb_topics, phpbb_users.
Here's my SQL statement so far:
This works so far but the problem I'm running in to is grabbing the last posted author's username, how do I fit that in to my statement? I need one last header to turn up called topic_last_post_username. Any help would be appreciated.
SELECT phpbb_topics.topic_id, phpbb_topics.topic_title, phpbb_topics.topic_replies, phpbb_topics.topic_views, phpbb_topics.topic_last_post_id, phpbb_users.username AS topic_username, phpbb_posts.post_time AS topic_last_post_time
FROM phpbb_topics, phpbb_users, phpbb_posts
WHERE phpbb_topics.forum_id = 2 AND phpbb_topics.topic_poster = phpbb_users.user_id AND phpbb_posts.post_id = phpbb_topics.topic_last_post_id
ORDER BY topic_views DESC LIMIT 5
My assumption is that I can't do this and that I actually need to have another SQL statement going to get that specific information aside from my current statment. Thanks.