Order Details Across Three Tables
Medium
Joins
For every order return the order id, the customer's name, the product name and the product price. Order by order id.
Table schema
Customers(id INT PRIMARY KEY, name VARCHAR(50))
Products(id INT PRIMARY KEY, name VARCHAR(50), price INT)
Orders(id INT PRIMARY KEY, customer_id INT, product_id INT)Sample data
Customers:
id | name
1 | Aman
2 | Riya
Products:
id | name | price
1 | Pen | 10
2 | Book | 50
Orders:
id | customer_id | product_id
1 | 1 | 2
2 | 2 | 1
3 | 1 | 1
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.