SitePoint Sponsor |
|
User Tag List
Results 1 to 1 of 1
Thread: inner joins
-
Jan 7, 2005, 11:33 #1
- Join Date
- May 2002
- Location
- Barcelona, Spain
- Posts
- 434
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
inner joins
Hello. If I need to use INNER JOIN to join multiple tables together, but one table to more than one other table, what is the proper syntax? Do I have to create different aliases for that table for each INNER JOIN?
eg. (this is pretty ugly)
PHP Code:SELECT DISTINCT po.products_options_name, pov.products_options_values_name, p.products_price, t.tax_rate, c.products_id AS id, c.customers_id, c.customers_basket_quantity as quantity, c.customers_basket_date_added as date, pd.products_name
FROM
products_options_values pov INNER JOIN customers_basket_attributes cba ON pov.products_options_values_id = cba.products_options_value_id ,
products_options po INNER JOIN customers_basket_attributes ON po.products_options_id = customers_basket_attributes.products_options_id,
products_description pd INNER JOIN customers_basket c ON pd.products_id = c.products_id,
products p INNER JOIN tax_rates t ON p.products_tax_class_id = t.tax_class_id,
products INNER JOIN customers_basket ON products.products_id = customers_basket.products_id,
customers_basket cb INNER JOIN customers_basket_attributes cba2 ON cb.customers_id = cba2.customers_id,
customers_basket cb2 INNER JOIN customers_basket_attributes cba3 ON cb2.products_id = cba3.products_id
WHERE c.customers_id =1 AND pd.language_id = 2
AND po.language_id =2 AND pov.language_id = 2;
Is there a way to join say table customers_basket with different tables in one simpler statement?
Bookmarks