I'm pretty new to SQL/PHP and I'm trying to LEFT JOIN two tables with the second table LEFT JOINed twice. Here the scenario: I have two tables, products and productvariations. In the productvariations table I also have a column 'colorvalue' that tells the user whether it's the standard color or a special color for the products.
products
idproducts | product | checked
-------------------------------
1 | testpr1 | 0
2 | testpr2 | 0
...
productvariations
productid | colorvalue | price
-------------------------------
1 | 0 | 12.50
1 | 1 | 10.25
2 | 0 | 14.50
2 | 1 | 13.00
...
Now what I want to do is to SELECT all columns of products and LEFT JOIN to them the twice the productvariations table to have two different additional columns for the price. But only those products that have the checked value = '0'. From different other Q&A I set up this code, but somehow it doesn't give me any results. Can someone help?
SELECT products.*, productvar1.price_single, productvar1.price_palette, productvar2.price_single, productvar2.price_palette, productvar1.price_specialconditions, productvar1.price_colorchange
FROM products
LEFT JOIN productvariations AS productvar1
ON products.idproducts = productvar1.product AND productvar1.colorvlaue = '0'
LEFT JOIN productvariations AS productvar2
ON products.idproducts = productvar2.product AND productvar2.colorvalue = '1'
WHERE products.checked = '0' LIMIT 200;