title: counting items from a multi level category tree that belong to a certain upper level tree in MYSQL
body: <p>So suppose I have a table named categories...it contains...well...categories</p>
  
  <p>table categories contain fields 'id', 'name' and 'parentID'</p>
  
  <pre><code>Table Categories:
  id    name     parentID
  1    cat1      null
  2    cat2      null
  3    cat3      null
  </code></pre>
  
  <p>Further it also contains subcategories that are children categories of the categories above. So:</p>
  
  <p>Table Categories:</p>
  
  <pre><code>id    name     parentID
  1    cat1      null
  2    cat2      null
  3    cat3      null
  4    cat4      1
  5    cat5      1
  6    cat6      2
  7    cat7      2
  8    cat8      3
  9    cat9      3
  </code></pre>
  
  <p>And suppose we have items that belongs to categories.....so we have the table item:</p>
  
  <pre><code>id name catID
  1  boo   9
  2  kya   8
  3  muwa  6
  4  haha  7
  </code></pre>
  
  <p>and I want to count the number of items that belongs to a certain category including its subcategories. So if I wanna count items that belong to cat3, it should return 2 items since boo and kyaa belong to category 9 and 8 which in turn are subcategories of cat3...</p>
  
  <p>what mysql query would you recommend me execute to go about implementing this?</p>