UNION, INTERSECT, EXCEPT
Combine compatible result sets with UNION, find common rows with INTERSECT, and find the difference with EXCEPT.
Set Operations Overview
Three set operators combine result sets row-by-row:
UNION— rows in A OR B (deduplicated)INTERSECT— rows in A AND BEXCEPT— rows in A but NOT in B
UNION
Combine two result sets, removing duplicates:
SELECT email FROM users
UNION
SELECT email FROM newsletter_subscribers;