1SELECT
2 a.name AS employee_a,
3 b.name AS employee_b,
4 a.department_id
5FROM employees a
6JOIN employees b ON a.department_id = b.department_id;
7-- Returns self-pairs (Alice, Alice) and both (Alice, Bob) and (Bob, Alice)
8-- 50 employees in same dept = 2,500 rows instead of 1,225
no lines flagged
#026PracticeMedium18 min · 120 XP
Self-Join Produces Cartesian Product
A query to find pairs of employees in the same department returns a massive result set with duplicates and self-pairs.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.