11.4 INTERSECT / EXCEPT
Level: 11 | Version: v1.1 | Author: Meptrasoft
Overview
INTERSECT and EXCEPT compare the results of two SELECT queries.
| Operator | Purpose |
|---|---|
INTERSECT |
Returns rows present in both results |
EXCEPT |
Returns rows from the first result that are not in the second |
INTERSECT → Common rows EXCEPT → First result only

Practice Tables
This topic reuses the employees and contractors tables from 11.3.
INTERSECT
INTERSECT returns rows that appear in both query results.
SELECT name, department, salary
FROM employees
INTERSECT
SELECT name, department, salary
FROM contractors;
The result contains rows that match in all selected columns.
INTERSECT → Common rows
EXCEPT
EXCEPT returns rows from the first SELECT result that do not appear in the second.
SELECT name, department, salary
FROM employees
EXCEPT
SELECT name, department, salary
FROM contractors;
With the original practice data, this returns no rows because every employee row also appears in contractors.
EXCEPT → First result minus second result
Simple Comparison
INTERSECT
A ∩ B
→ COMMON ROWS
EXCEPT
A − B
→ FIRST RESULT ONLY
For example:
A = Alice, Bob, Carol
B = Alice, Carol, David
INTERSECT → Alice, Carol
EXCEPT → Bob
Important Rule
As with UNION, the two SELECT statements must return the same number of columns, with compatible data types in corresponding positions.
SELECT name, salary FROM employees
INTERSECT
SELECT name, salary FROM contractors;
Common Beginner Mistakes
| ✗ Mistake | ✓ Correct Understanding |
|---|---|
INTERSECT returns all rows from both queries |
It returns only common rows |
EXCEPT compares tables permanently |
It compares query result sets |
EXCEPT returns rows unique to both sides |
It returns rows from the first result that are absent from the second |
| The SELECTs can have different columns | They must have the same number of compatible columns |
| Column order does not matter | Corresponding columns must be compatible |
Placement Quick Points
INTERSECT
→ COMMON RESULTS
EXCEPT
→ FIRST RESULT ONLY
INTERSECTreturns common rows.EXCEPTreturns rows from the first result that are not in the second.- Both operate on
SELECTresult sets. - Corresponding queries must return the same number of compatible columns.
- These operators are useful for comparing datasets.
Interview Questions
- What is INTERSECT?
INTERSECTreturns rows that exist in bothSELECTresults.- What is EXCEPT?
EXCEPTreturns rows from the firstSELECTresult that do not exist in the second.- What is the difference?
INTERSECT → Common rows EXCEPT → First result only- What requirement applies to both queries?
They must return the same number of columns with compatible data types in corresponding positions.
- How can EXCEPT be useful?
It can help identify records that exist in one dataset but not another.
Practice & Hands-On Exercises
Using employees and contractors:
- Find rows common to both tables using
INTERSECT:
SELECT name, department, salary FROM employees
INTERSECT
SELECT name, department, salary FROM contractors;
- Find employee rows that are not present in
contractorsusingEXCEPT:
SELECT name, department, salary FROM employees
EXCEPT
SELECT name, department, salary FROM contractors;
- Explain the difference between
INTERSECTandEXCEPT. - Identify how these operators can help compare two datasets.
💡 Tip: Test your queries using the in-browser interactive runner above.
Key Takeaway
INTERSECT → COMMON
EXCEPT → FIRST ONLY
INTERSECT finds common rows between two query results, while EXCEPT finds rows that exist only in the first result.
End of INTERSECT / EXCEPT