SQLIntermediate#sets

What are INTERSECT and EXCEPT/MINUS?

INTERSECT returns rows present in both queries; EXCEPT (MINUS in Oracle) returns rows in the first query that are not in the second. Both remove duplicates.

Example
SELECT id FROM active_users
INTERSECT
SELECT id FROM paying_users;

SELECT id FROM all_users
EXCEPT
SELECT id FROM banned_users;

Related Questions

1
SQLIntermediate#indexes#performance

What is an index? What are the trade-offs?

Open
2
SQLAdvanced#indexes

Clustered vs non-clustered index?

Open
3
SQLAdvanced#indexes#performance

What is a covering index?

Open