Complex SQL statement please help
Posted: Sun Mar 11, 2007 5:46 am
Hi
I have three tables - products,manufacturers,classifications. The products table contains the primary keys - ManufacturerID and ClassificationID - of the Manufacturers and Classifications tables, which refer to the titles associated with these keys within these tables.
I want to carry out an SQL query that returns the respective ManufacturerTitles and ClassificationTitles from the Manufacturers and Classifications tables, corresponding to the keys stated against products (ManufacturerID and ClassificationID) in the Products table.
The above query does not work, because I'm not used to using left joins, in fact any joins at all!
I would be grateful for any help.
Many thanks
Code: Select all
select products.*, manufacturers.ManufacturerTitle, classifications.ClassificationTitle from products left join manufacturers,classifications on products.ClassificationID=classifications.ClassificationID and products.ManufacturerID=manufacturers.ManufacturerID limit 0,20I want to carry out an SQL query that returns the respective ManufacturerTitles and ClassificationTitles from the Manufacturers and Classifications tables, corresponding to the keys stated against products (ManufacturerID and ClassificationID) in the Products table.
The above query does not work, because I'm not used to using left joins, in fact any joins at all!
I would be grateful for any help.
Many thanks