Got a problem that has probably been answered a million times before I'm sure, but I can't quite put other people's solutions into the context of my database.
I have two tables:
tbl_forum_threads
thread_id
thread_author
thread_title
thread_category_id
thread_stickied
tbl_forum_replies
reply_id
thread_id
reply_author
reply_text
reply_date
As you can probably guess this is for a forum I am working on.
I am trying to get my main forum page to display threads in order of most recently posted into. The problem I have at the moment is that the query below actually sorts them into the order they were created and not the order they were posted into.
The query I have at the moment refers to some other tables, but for the sake of the tables above and to keep things simple, can anyone get my query to do what I want it to?
SELECT a.*, UNIX_TIMESTAMP(b.reply_date) AS reply_date, c.category_name, d.user_id, d.username
FROM
tbl_forum_threads a, tbl_forum_replies b,
tbl_forum_categories c, tbl_users d
WHERE
a.thread_author = d.user_id
AND a.thread_id = b.thread_id
AND a.thread_category_id = c.category_id
GROUP BY a.thread_id ORDER BY a.thread_stickied ASC, reply_date DESC