How to create INNER JOIN multiple tables in sql
21,484
Try this:
SELECT pr.price_id, p.product_name v.vendor_name, pr.price
FROM Prices AS pr
LEFT JOIN Products AS p ON p.product_id = pr.product_id
LEFT JOIN Vendors AS v ON v.vendor = pr.vendor_id
Author by
user_unknown
Updated on March 20, 2020Comments
-
user_unknown about 4 years
I have 3 tables: Products, Vendors and Prices. Prices has product_id and vendor_id as foreign keys. Now i want to show Prices as:
price_id:product_name:vendor_name:price
Something like:
SELECT p.product, v.vendor, pc.price FROM Products AS p, Vendors AS v INNER JOIN Prices AS pc ON p.product_id = pc.product_id INNER JOIN Prices AS pc ON v.vendor = pc.vendor_id
but I didnt get it work.