title: Receive product groups and products with one query
body: <p>I have two tables:</p>
  
  <pre><code>Product
  ------------------------------------
  id   group_id   name   quick_select
  ------------------------------------
  1      1       product1      1
  2      3       product2      0
  3      5       product3      1
  
  Product_group
  -----------------------
  id   name   parent_id
  -----------------------
  1   group1     0
  2   group2     0
  3   group3     1
  4   group4     1
  5   group5     3
  </code></pre>
  
  <p>I making a navigation system for quick select products. I show categories to user and user can navigate in them by clicking category button, then goes level down to subcategory and goes down so many levels that finally it can't go deeper - then I show products. First I show root categories where there's products under them and under those root categories subcategories, subsubcategories and so on. </p>
  
  <p>In my query I want select all root categories (where parent_id=0), if there's products in them and in their subcategories and subsubcategories and so on, where quick_select must be 1 in product table. And I don't know the deepness of categories - how many levels there are.</p>
  
  <p>Is it possible with one query? Or do I need to do two queries?</p>
  
  <p>I made so far, with this query:</p>
  
  <pre><code>SELECT pg.id, pg.name, pg.parent_id AS parent_id
  FROM product_group AS pg
  LEFT JOIN product AS p ON pg.id = p.group_id
  WHERE pg.parent_id = 0 AND p.id IS NOT NULL AND p.quick_select = 1
  GROUP BY pg.id
  </code></pre>
  
  <p>But I don't receive root categories which subcategory is empty, which subcategory is empty and under this is one more subcategory with products with quick_select=1.</p>
  
  <p>Sorry for my bad english.</p>
  
  <p>I want to receive all categories where products with quick_select=1 are, not products</p>
  
  <pre><code>-- Category
  |     |
  |   product
  |
  -- Category
        |
     Category
        |
     Category
        |
   multiple products 
  </code></pre>