I am trying to find a way to figure out which thread has the most replies in my forum. Here is the query that I am using to get my information from the database:
PHP Code:
$q "SELECT f.forum_id, f.name, f.description, first_name, t.thread_id, t.subject, p.posted_on, p.message, COUNT(p.post_id) AS posts, COUNT(t.forum_id) AS threads FROM forums AS f INNER JOIN threads AS t USING (forum_id) LEFT JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.forum_id = f.forum_id GROUP BY (f.forum_id) ORDER BY posts DESC LIMIT $start$display"
I then use a while loop to display the information in a table. What could I use to narrow down the thread with the most replies that would work with my while loop?

Any suggestions would be helpful.