INNER JOIN
Returns only the rows that have a match in both tables. Rows without a partner disappear from the result.
Formularows with a match on both sides only
How we work it through
- 1
Ask who has no partner and whether they matter for the question.
- 2
Count the left table before and after the join.
- 3
Use LEFT JOIN when people without a match must stay in the answer.
On the practice dataset
The query we run on Meridian, Atterna’s practice marketplace, and what it returns.
SELECT COUNT(DISTINCT b.buyer_id)
FROM meridian.buyers b
JOIN meridian.orders o ON o.buyer_id = b.buyer_id;Result3,705 of 7,000 buyers — the 3,295 who never ordered disappear
The common trap
Losing rows silently: customers with no orders vanish, so a count of customers after the join is too low.
When an AI answers
An AI assistant
“Average orders per buyer is 2.5.”
- What it didn’t know
- The INNER JOIN dropped every buyer with no orders, so the average covers only those who ordered.
- Ask back
- “Does the average include buyers with zero orders?”
Read next
Examples use Meridian, Atterna’s fictional practice marketplace.