How do i properly build an 'efficient' query for this simple situation??
Im trying to output the last 5 threads of a message board. The output data will be:
Thread title,
forum name (from what forum it came from )
poster (the user who started the thread )
This would involve 2 tables:
topics and forums
.. where the topics table contain the topic title , the thread starter and the FORUM ID.
and ofcourse I will have to pull out the forum name from the Forums table using the forum_id in the topics table
I could build a query for the topics such as:
SELECT title, forum_id, poster FROM topics ORDER BY start_date DESC LIMIT 5
...and then build another query for the forum name for each of the result like this
SELECT forum_name FROM forums WHERE forum_id ='$forum_id'
The above would surely work but i wanted to know if there is a more efficient way to doing this? I was thinking of joining tables, but I CANT SEEM TO FIGURE OUT THE RIGHT FORMULA.. coz, there is no "WHERE" clause like a normal table join operation would have.
Any ideas?