title: deleting nested categories from a table
body: <p>I have a table called <code>categories</code> which looks like this</p>
  
  <pre><code>+-------------+--------------+---------------+
  |  id         |  catName     |  parentId     |
  +-------------+--------------+---------------+
  |  1          | Category 1   |  0            |
  |  2          | Category 2   |  0            |
  |  3          | Sub Cat 1    |  1            |
  |  4          | Sub Cat 2    |  1            |
  |  5          | Sub sub cat 1|  4            |
  |  6          | Sub sub cat 2|  4            |
  |  7          | Category 2   |  0            |
  +-------------+--------------+---------------+
  </code></pre>
  
  <p>It would be easy to delete a category and its direct child:</p>
  
  <pre><code>mysql_query("DELETE FROM `categories` WHERE `id`='$id'");
  mysql_query("DELETE FROM `categories` WHERE `parentId`='$id'");
  </code></pre>
  
  <p>However I need to be able to delete ALL children of a category. For example if <code>Category 1</code> was deleted <code>Sub Cat 1</code>, <code>Sub Cat 2</code>, <code>Sub sub cat 1</code>, <code>Sub sub cat 2</code> will be deleted</p>
  
  <p>Any help appreciated.</p>