Quote:
Originally Posted by barryhand
Another question, I have a query to show the last 10 threads from any forum with the title of the thread, the poster and the date. I want to add in the forum that it was posted in.
E.g
Forum - Thread Title - Poster - Time.
Do i need to query 2 tables for this, how ?
Here's the code i have already
|
Two tables, yes. Thread table and forum table
Code:
SELECT " . TABLE_PREFIX . "thread.threadid AS threadid, " . TABLE_PREFIX . "thread.title AS title, " . TABLE_PREFIX . "thread.postusername AS postusername," . TABLE_PREFIX . "thread.postuserid AS postuserid," . TABLE_PREFIX . "thread.dateline AS dateline," . TABLE_PREFIX . "forum.description AS description
FROM " . TABLE_PREFIX . "thread LEFT JOIN " . TABLE_PREFIX . "forum ON " . TABLE_PREFIX . "thread.forumid=" . TABLE_PREFIX . "forum.forumid
WHERE " . TABLE_PREFIX . "thread.sticky=0 AND " . TABLE_PREFIX . "thread.visible=1
ORDER BY dateline DESC
LIMIT 10
I tried the above in a query window not using " . TABLE_PREFIX . ", so, you might find an error in my pasting of the " . TABLE_PREFIX . " into the sql statement.