I'm having some trouble getting the number of posts and topics for each of the forums on the database. I can get these values doing 2 queries but I wonder if it is possible to do it with only one query.
This query gets the number of topics per forum:
select forums.forumId, forums.forumName, count(*) as Topics FROM Topics
INNER JOIN forums ON forums.forumId = topics.forumID
GROUP BY forums.forumId;
This query gets the number of posts per forum:
select forums.forumId, forums.forumName, count(*) as Posts FROM posts
INNER JOIN topics ON topics.topicID = posts.topicId
INNER JOIN forums ON forums.forumId = topics.forumID
GROUP BY forums.forumId;
How do I get both post and topic count in just one query?