INNER JOIN returns only the rows where the join condition matches in both tables.
Order 1012 belongs to customer 99, who does not exist, so it does not appear in an inner join.
You can join more than two tables by adding more JOIN clauses.
Rows that match in both tables.
✍️ 3 exercises + code challenge in this lessonINNER JOIN returns only the rows where the join condition matches in both tables.
Order 1012 belongs to customer 99, who does not exist, so it does not appear in an inner join.
You can join more than two tables by adding more JOIN clauses.
Mastering SQL INNER JOIN helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
SELECT o.OrderID, c.CustomerName, p.ProductName, i.Quantity,
p.Price * i.Quantity AS LineTotal
FROM Orders o
INNER JOIN Customers c ON c.CustomerID = o.CustomerID
INNER JOIN OrderItems i ON i.OrderID = o.OrderID
INNER JOIN Products p ON p.ProductID = i.ProductID
ORDER BY o.OrderID;
Check what you learned in “SQL INNER JOIN”.
Return only matching rows from both tables.
SELECT * FROM Orders Customers ON Orders.CustomerID = Customers.CustomerID;
Order 1012 belongs to customer 99, who does not exist. Does it appear in an INNER JOIN?
Select ProductName and Quantity from OrderItems joined with Products for OrderID 1001, sorted by ProductName.
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services