Lesson 16 / 37 · Joins
A join can multiply rows
Four departments go in, five rows come out: Engineering and Sales each match two employees and appear twice, Research matches nobody and vanishes. A join is not a lookup; every match is a row, and anything summed later counts those copies.
The query
SELECT d.name AS department, e.name AS employee
FROM departments d
JOIN employees e ON e.dept_id = d.id
Try SELECT DISTINCT d.name AS department: the copies collapse to 3 rows, which hides the fan-out instead of explaining it.
Next: A WHERE on the right table turns LEFT JOIN into INNER JOIN · All lessons