I am currently trying to fetch forum topics based on the amount of replies that has been submitted for a topic. I am somewhat new to understanding how SQL joins work, though I have been using SQL for awhile in general, though I feel like I am on the right track. I currently have this query:
SELECT * FROM `topics` INNER JOIN ( SELECT COUNT(tid) as countedReplies,`tid` FROM `replies` GROUP BY `tid` ) ON topics.id = replies.tid ORDER by replies.countedReplies DESC
Table structures look something like this:
ID Topic Name 1 Filler Topic Name 2 Exciting Posts about Excellence 3 Random name for example
ID tid Post 1 3 Hooray! Wonderful! 2 3 I am a post to topic id 3 as well! 3 1 Topic 1 is better than topic 1.
My expected result
I am getting nothing in return, though I am trying to get something like this:
1. Random name for example 2. Filler Topic Name 3. Exciting Posts about Excellence