title: SQL | Get products and product variants
body: <p>I got the following mysql structure:</p>
  
  <pre><code>`product`
  id  |   name        |   quantity    | unit
  10  |   Color bath  |   12          |   L
  20  |   Color house |   15          |   L
  
  `product_variant`
  id  |   masterid    |   name        |   quantity    |   unit
  100 |   10          |   Color bath  |   10          |   L
  200 |   10          |   Color bath  |   20          |   L
  300 |   20          |   Color house |   20          |   L
  </code></pre>
  
  <p>What our query should return:</p>
  
  <p>Give me all products and give me all productvariants from this product and return for each product / product_variant a line:</p>
  
  <pre><code>product.id as masterid, product.id/product_variant.id, product.name, product.quantity/product_variant.quantity, product.unit/product_variant.unit
  10, 10, Color bath, 12, L
  10, 100, Color bath, 10, L
  10, 200, Color bath, 20, L
  20, 20, Color house, 15, L
  20, 300, Color house, 20, L
  </code></pre>
  
  <p>We tried it using a UNION SELECT but this seems to be not the right solution. It takes up to 2 seconds for 10.000 rows (with using indexes).
  Is there any other chance to get what we need without using UNION?</p>