SQL INNER JOIN

Rows that match in both tables.

✍️ 3 exercises + code challenge in this lesson

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.

Key Takeaways: SQL INNER JOIN

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.

SQL INNER JOIN Code Example

SQL
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;
Free sign-in required · Google login available

SQL INNER JOIN Practice Exercises

Check what you learned in “SQL INNER JOIN”.

/ 3 solved
Fill in the blank

Return only matching rows from both tables.

SELECT * FROM Orders  Customers ON Orders.CustomerID = Customers.CustomerID;
✓ Correct! Not quite. Try again.
Multiple choice

Order 1012 belongs to customer 99, who does not exist. Does it appear in an INNER JOIN?

✓ Correct! Not quite. Try again.
Code challenge

Select ProductName and Quantity from OrderItems joined with Products for OrderID 1001, sorted by ProductName.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

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