title: select all products from child categories in parent category
body: <p>I have the following 'categories' table:</p>
  
  <pre><code>+--------+---------------+----------------------------------------+
  | ID     | Parent ID     | Name                                   |
  +--------+---------------+----------------------------------------+
  | 1      | 0             | Computers                              |
  | 2      | 1             | Apple                                  |
  | 3      | 1             | HP                                     |
  | 4      | 2             | Macbook Air                            |
  | 5      | 2             | Macbook Pro                            |
  | 6      | 1             | Dell                                   |
  | 7      | 6             | Inspiron                               |
  | 8      | 6             | Alienware                              |
  | 9      | 8             | Alienware 13                           |
  | 10     | 8             | Alienware 15                           |
  | 11     | 8             | Alienware 17                           |
  | 12     | 0             | Smartphones                            |
  | 13     | 12            | Apple                                  |
  | 14     | 12            | Samsung                                |
  | 15     | 12            | LG                                     |
  +--------+---------------+----------------------------------------+
  </code></pre>
  
  <p>Let's say I have the following 'products' table:</p>
  
  <pre><code>+--------+---------------+----------------------------------------+
  | ID     | Category ID   | Name                                   |
  +--------+---------------+----------------------------------------+
  | 1      | 13            | Apple iPhone 8                         |
  | 2      | 13            | Apple iPhone 8 Plus                    |
  | 3      | 14            | Samsung Galaxy S8                      |
  +--------+---------------+----------------------------------------+
  </code></pre>
  
  <p>With the following query, I select all the products in a category:</p>
  
  <pre><code>SELECT
      id,
      name
  FROM
      products
  WHERE
      category_id = ?
  </code></pre>
  
  <p><strong>Ok, my question:</strong></p>
  
  <p>The product 'Apple iPhone 8' is in the category <em>Apple</em>, this is a subcategory of the category <em>Smartphones</em>. If I replace the '?' in my query with 13 (the category ID of <em>Apple</em>), I get the product. When I replace the '?' in my query with 12 (the category ID of <em>Smartphones</em>), I don't get the product. I want to select all products that are <strong>in the category or in one of the child/grandchild/... categories</strong>. How can I do this with a single query (if possible)?</p>