0

I have this table forum and topic and i want to query forumname, description, total topics in the Forum idk how to do this

i tried an sql statement like this

SELECT f.forumname,f.forumdesc,max(t.forum) as total_topics from Forum as f INNER JOIN Topic as t WHERE f.forumid = t.forumid;

of course this did not work it returns only a single tuple like
|forumname|forumdesc |total_topics
|PHP |description here| 100

the number 100 in total_topics are the total number of all topics in the database;

the output i want is a list of all forums with there corresponding names,description and the total number of topics in each forum...

for now i have created a function in php to get the total number of topics in a forum but maybe its better if i can query 1 table for all of those information I want, if its possible. . .

thanks!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by urtrivedi
0
SELECT f.forumname,f.forumdesc,count(*) as total_topics from Forum as f 
INNER JOIN Topic as t WHERE f.forumid = t.forumid
group by f.forumname,f.forumdesc;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.