title: mysql count subtables and its subtables for its main table
body: <pre><code>Table 1 - Category
  
  id | name
  
  Table 2 - subcat
  
  id | cid(category.id) | name
  
  Table 3 - products
  
  id | cid(category.id) | sid(subcat.id) | name
  
  select a.* , count(b.id) as total
           from category a left join
           subcategory b on a.id=b.cid 
           group by a.id order by a.name
  </code></pre>
  
  <p>this gives the count of sub categories for each category</p>
  
  <p>and I can run seperately for products so that i will get count of products for each category</p>
  
  <p>what I want is the count of subcategories and the count of products for each category. How to form the query?</p>
  
  <p>It should be like catename, count of (sub categories) and count of (products)</p>