Sql Join filter
Posted on 2005-04-21
With the following sql:
IF (products_groups.customers_group_price IS NULL, products.products_price, products_groups.customers_group_price) AS products_price
FROM products_description pd, products_to_categories ptc, products
LEFT JOIN products_groups ON products.products_id = products_groups.products_id
WHERE pd.products_id = products.products_id AND ptc.products_id = products.products_id
ORDER BY products_price;
How can I filter the join so that 'products_groups.customers_group_price' is only selected for the condition in the if statement BUT also only where 'products_groups.customers_group_id = 2'?
I've put '2' to simplifier the question, where as actually it will be a variable.