Set operations combine the results of two SELECT statements that return the same number of columns with compatible types — rather than combining columns side-by-side like a join, they stack or compare entire result sets:
-- UNION: every distinct dept name that appears in either table
SELECT dept FROM Employees
UNION
SELECT dept FROM Departments;
-- UNION ALL instead of UNION keeps duplicates and skips the (often costly) de-duplication step
-- INTERSECT: dept names that appear in BOTH result sets
SELECT dept FROM Departments
INTERSECT
SELECT dept FROM Employees;
-- Finance is excluded — no employee has dept = 'Finance'
-- EXCEPT (called MINUS in Oracle): rows in the first result set, absent from the second
SELECT dept FROM Departments
EXCEPT
SELECT dept FROM Employees;
-- returns only Finance — the department with zero employees, found without a single JOIN
That EXCEPT query is worth sitting with: it answers "which departments have no employees" using pure set logic, no LEFT JOIN ... WHERE ... IS NULL pattern required — a genuinely useful alternative worth knowing, even though the LEFT JOIN version (covered in the very first chapter) is more common in practice and generalizes better once you also want columns from both sides.