INTERSECT and EXCEPT

INTERSECT returns the rows present in both results, EXCEPT those of the first result that are absent from the second (MINUS in some engines). These set operators compare entire rows, deduplicate by default and require compatible columns.

Example

SELECT id FROM clients
EXCEPT
SELECT client_id FROM commandes;

Related concepts

The whole glossary