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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With