title: get all products that are in nested categories
body: <p>I would really appreciate some help on this. my teacher couldn't help me.</p>
  
  <p>Anyway I have 3 tables</p>
  
  <p>tbl_product:</p>
  
  <pre><code>PID | productname
  1   | product 1
  2   | product 2
  3   | product 3
  4   | product 4
  ..
  </code></pre>
  
  <p>tbl_categories, motherCategory allows me to nest categories:</p>
  
  <pre><code>CID | categoriename    | motherCategory
  1   | electronics      | NULL
  2   | clothing         | NULL
  3   | Arduino          | 1
  4   | Casings, extra's | 3
  ..
  </code></pre>
  
  <p>tbl_productInCategory PID and CID are foreign keys to PID and CID in tbl_product and tbl_categories respectively. A product can have multiple categories assigned to it so PID can occur more than once in this table.</p>
  
  <pre><code>PID | CID
  1   | 3
  2   | 3
  3   | 4
  4   | 4
  </code></pre>
  
  <p>I want to select all products that are in a given category + it's subcategories. For instance if I give it the parameter CID = 1 (Electronics) it should also return the products in arduino and Casings, extra's.</p>
  
  <p>I can't figure out how to do this and any help or pointers are appreciated.</p>