select name,(select count(*)
from tableTopics where
belongsInForum = tf.id) as numberOfTopics,
(select count(*) from tablePosts
where BelongsTopic in (
select id from tableTopics
where BelongsInForum = tf.id)) as numberOfPosts
from tableForums tf
Trådstart#1
Jag håller på och bygger ett forum och har följande tabeller liggande i en SQL 2000-databas:
tableForums
ID | Name
tableTopics
ID | BelongsInForum | Title
tablePosts
ID | BelongsToTopic | Title
Mellan tableForums.ID och tableTopics.BelongsInForum finns det en relation, vilket det även gör mellan tableTopics.ID och tablePosts.BelongsToTopic
På forumets förstasida vill jag visa forumets titel, antal topics, samt antal posts.
Hur gör men det på ett bra sätt?