List Orders with Product Details in SQL
×
Join our community on Telegram!
Join the biggest community of Pharma students and professionals.
List Orders with Product Details in SQL
orders Table:

OrderDetails Table:

producs Table:

Query Explanation:
● SELECT Orders.OrderID, Products.ProductName, OrderDetails.Quantity, Products.Price
Displays each order's ID, the name of the product in the order, quantity ordered, and the product's price.
● FROM OrderDetails
Begins with the OrderDetails table, which connects orders to products.
● JOIN Orders ON OrderDetails.OrderID = Orders.OrderID
Links each order detail to its corresponding order using the OrderID.
● JOIN Products ON OrderDetails.ProductID = Products.ProductID
Links each order detail to the product details using the ProductID.
SQL Query:
USE SalesInventoryDB;
select orders.OrderID,
products.ProductName,
orderdetails.Quantity,
products.UnitPrice
from orderdetails
join orders on orderdetails.OrderID= orders.OrderID
join products on orderdetails.ProductID = products.ProductID;
Output:

