SQL JOIN (INNER JOIN)

A JOIN combines rows from two tables using a matching column, usually an id. JOIN on its own means INNER JOIN: it keeps only rows that have a match on both sides.

Updated December 1, 2026

Syntax

SELECT a.column, b.column
FROM table_a AS a
JOIN table_b AS b ON b.id = a.b_id;

Join two tables

Each order stores a customer_id. Joining to customers swaps that id for a name.

SELECT o.id, c.name, o.quantity
FROM orders AS o
JOIN customers AS c ON c.id = o.customer_id
ORDER BY o.id;
Result on the SQL Café sample data (10 rows, first 6 shown)
idnamequantity
1Ava1
2Ava2
3Ben1
4Cara1
5Dev3
6Eli1

Join three tables

Add another JOIN for each table. Now every order shows who bought what.

SELECT o.id, c.name AS customer, d.name AS drink
FROM orders AS o
JOIN customers AS c ON c.id = o.customer_id
JOIN drinks AS d ON d.id = o.drink_id
ORDER BY o.id;
Result on the SQL Café sample data (10 rows, first 6 shown)
idcustomerdrink
1AvaLatte
2AvaHot Chocolate
3BenCold Brew
4CaraMatcha Latte
5DevEspresso
6EliLatte

Types of join

Common mistakes

Practice JOIN (INNER JOIN) interactively

Write real queries in your browser and get instant feedback in the lesson “INNER JOIN” (Unit 5). New learners can start free from the first lesson.

Frequently asked questions

Is JOIN the same as INNER JOIN?

Yes. INNER is optional.

Why did my join return more rows than expected?

One row matched several rows on the other side (a one-to-many relationship). That’s often correct; if not, check your ON condition or aggregate first.

Related SQL tutorials