Nam Hao Nam Hao - 2 years ago 72
SQL Question

How to count total comment in a category not a topic

My database:

category (cat_id,cat_name)
topic (topic_id,cat_is)

Now I want to count total comment in a category.

Answer Source
select cat_id, count(1) cnt 
     from category 
     join topic on cat_is = cat_id
     join comment on topic_is = topic_id
  group by cat_id
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download