I have troubles making a mySQL query (which I`m going to execute on a phpbb forum db)
I have 3 tables
1. topics
2. posts
3. users
What I want to get is the username of the first and last poster of a topic.
So "posts" table contains IDs, posts and their authors/posters` ID. "topics" table contains the id of the last and first poster`s IDs of each topic. Finally "users" table contains usernames and their IDs.
So, if I want to get the username of the first poster on a topic I use:
SELECT u.username FROM users as u, topics as t, posts as p
WHERE t.first_post_id=p.post_id AND p.poster_id=u.user_id
And when I want to get the username of the last poster, I use this:
SELECT u.username FROM users as u, topics as t, posts as p
WHERE t.last_post_id=p.post_id AND p.poster_id=u.user_id
Now, how can I get BOTH last poster and first poster in a topic? I mean, how to merge these 2 queries?
Any help appreciated!