Part 1 of 5 · 1 min read
Why this page comes first
In this module you will
- Use UNION, UNION ALL, INTERSECT and EXCEPT correctly.
- Explain the one structural rule every set operation requires of its two queries.
- Explain when UNION ALL is both correct and clearly faster than UNION.
- Rewrite an EXCEPT query using a subquery, and recognize when each form reads more clearly.
Set operations combine the results of two separate queries directly, rather than joining tables row by row. This page covers all four, and the one rule that trips people up first: both queries must return the same number of columns, in compatible types.