intermediate
INTERSECT Operator
5 min readLast updated: 2026-07-23
Overview
The INTERSECT operator returns only the distinct rows that are present in both query result sets.
Learning Objectives
- Find overlapping observations between two datasets using
INTERSECT. - Enforce set intersection rules across matching schema columns.
Detailed Concept Explanation
INTERSECT calculates the mathematical intersection of two sets:
- If a row exists in Query A AND Query B, it is included in the output.
- Duplicate rows are automatically removed.
Code Examples
SQL
sql
-- Find customers who are ALSO registered as corporate partners
SELECT email FROM active_customers
INTERSECT
SELECT email FROM corporate_partners;
Summary
INTERSECT returns distinct rows that exist in both query result sets.