title: Get minimum price with left join / result reduced
body: <p>I am coding an online shop. A product has a default price, but since it might have different attributes (color, size, ...), those different attributes might result in different prices as well. At the moment I am trying to produce a mysql query which helps me to find the minimum and maximum possible price of a product. Using LEFT JOIN currently reduces the query's result to only one row and I don't know why.</p>
  
  <pre><code>SELECT
      products.id AS id,
      categories.name AS category_name,
      MIN(product_attributes.price) AS min_price, MAX(product_attributes.price) AS max_price,
      products.*
  FROM products
  LEFT JOIN categories ON category_id=categories.id
  LEFT JOIN product_attributes ON products.id=product_attributes.product_id
  </code></pre>
  
  <p>Is this even the correct approach? I do not know that much about mysql, I just try and try and I am happy if it works. Thanks for help anyway.</p>