Jess McKenzie
Jess McKenzie

Reputation: 8385

Adjusting SQL Query

I have the following query:

  SELECT product_description.name, product.quantity,product.price
    FROM product
    INNER JOIN product_description
    ON product.product_id=product_description.product_id
    ORDER BY product_description.name 

I need to incorporate a few more tables, I have tried the following but I am unsure how I will extend my ON beyond one pair.

Error: (ON line)

SELECT product_description.name, product.quantity,product.price,product_option_value_description.name
FROM product
INNER JOIN product_description, product_option_value_description
ON product.product_id=product_description.product_id=product_option_value_description.product_id
ORDER BY product_description.name

Upvotes: 0

Views: 51

Answers (2)

Marco
Marco

Reputation: 57603

SELECT pd.name,p.quantity,p.price,povd.name
FROM product p
INNER JOIN product_description pd ON p.product_id=pd.product_id
INNER JOIN product_option_value_description povd ON p.product_id=povd.product_id
ORDER BY pd.name

Upvotes: 2

Jesus Ramos
Jesus Ramos

Reputation: 23266

You must use a separate join for each table you want to join on

...
JOIN Table1 ON ...
JOIN Table2 ON ...
...

Upvotes: 4

Related Questions