Cellwise · SQL track
Combining results with INTERSECT and EXCEPT
Find what two results share, or what one has that the other doesn’t.
UNION combines two results. INTERSECT keeps only rows that appear in both, and EXCEPT keeps rows from the first that aren’t in the second.
All three remove duplicates. UNION ALL is the exception: it keeps every row, duplicates included. Each part must return the same number of columns.
What you’ll do
- In both lists
- In one list but not the other
- Keep the duplicates