Maxim Mironjuk
-
April 18, 2026
UNION and UNION ALL belong to the standard toolkit, but the two other set operators in the SQL standard, INTERSECT and EXCEPT, lead a shadow existence in many codebases, even though for certain questions they are the clearest and most maintainable solution available. INTERSECT answers which rows appear in two result sets at the same time, EXCEPT answers which rows appear in the first set but not the second. Both questions can also be solved with JOIN or NOT EXISTS constructs, but the set operator often makes the actual business intent visible at a glance. This article covers when switching is worth it, how syntax differs between databases, and how performance actually compares to the alternatives.