title: How to take count of sub-categories and update parent row count in mysql using single query?
body: <p>I am stroring categories and sub categories in same table. How can I take count of all subcategories and update my parent category row of data.</p>
  
  <pre>
  <b>categoryId   sub cat id    category_count        subcategory_count</b>
          1           3               0                      3              
          1           4               0                      1
          1           5               0                      7
          1           0               5                      0
  </pre>
  
  <p>I need to update category count with sum of sub category count.</p>
  
  <p><code>for eg;- 5 is my category count. I want my category count like this</code>
  <code>5+ (3+7+1) so my category count should be 16</code></p>
  
  <p>How can I write a single query for that.</p>
  
  <p>please help me
  Thanks</p>