How INNER JOIN Matches Rows
The row-pairing mental model that makes every join question easy.
The First Join Interviewers Ask
When an interviewer says "join these two tables", they almost always mean INNER JOIN. It is the default join and the one that reveals whether you really understand how rows get paired.
The whole topic reduces to one sentence: an INNER JOIN considers every possible pair of rows from the two tables and keeps only the pairs that satisfy the ON condition. No match means the row simply disappears from the result.
Lock in this mental model and every harder join question gets easier.
Two Tables to Reason About
Throughout this lesson we use two small tables. customers holds who placed orders, and orders records each order with the customer it belongs to.
customers(id, name)orders(id, customer_id, amount)
The link between them is orders.customer_id = customers.id. That equality is the join predicate the entire result depends on.
customers
id | name
1 | Ada
2 | Bob
3 | Cleo -- no orders yet
orders
id | customer_id | amount
10 | 1 | 50
11 | 1 | 20
12 | 2 | 99All lessons in this course
- How INNER JOIN Matches Rows
- ON vs WHERE in Joins
- Join Fan-Out and Row Multiplication
- Joining Three or More Tables