Set Operations

SQL set operations combine or compare the results of multiple queries.

EXCEPT

EXCEPT returns rows from the first query that are not in the second query.

SELECT student_id FROM students
EXCEPT
SELECT student_id FROM homework_submissions;

This asks: which students appear in the first result but not the second?

MINUS

Some databases use MINUS instead of EXCEPT.

Relation To Joins

SQL Joins combine columns from related rows. Set operations compare whole result sets. Use joins when relationships between tables matter. Use set operations when comparing query outputs.