Hi,
This SQL (from OS Commerce) is resulting in zero matches, while another with a different p2c.categories_id results in matches and I don't know why.
I was never good with left-joins, so I wonder if someone could help me split this up into chunks I can run to help me understand it.
Here's the SQL:
select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from ((products_description pd, products p) left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c) left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '3' order by pd.products_name
I guess it creates some tables on the fly and then compares those, I just don't know how to split this up so I can run it and see those intermediate results tables to see where the problem lies.
If anyone wants to write what it's doing in English, that would be super smashing lovely too.
Cheers
J
This SQL (from OS Commerce) is resulting in zero matches, while another with a different p2c.categories_id results in matches and I don't know why.
I was never good with left-joins, so I wonder if someone could help me split this up into chunks I can run to help me understand it.
Here's the SQL:
select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from ((products_description pd, products p) left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c) left join specials s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '3' order by pd.products_name
I guess it creates some tables on the fly and then compares those, I just don't know how to split this up so I can run it and see those intermediate results tables to see where the problem lies.
If anyone wants to write what it's doing in English, that would be super smashing lovely too.
Cheers
J