0PricingLogin
SQL Interview Prep · Lesson

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           | 99

All lessons in this course

  1. How INNER JOIN Matches Rows
  2. ON vs WHERE in Joins
  3. Join Fan-Out and Row Multiplication
  4. Joining Three or More Tables
← Back to SQL Interview Prep