Recall & Review
beginner
What does the SQL INTERSECT operator do?
It returns only the rows that appear in both SELECT query results, showing common rows between two datasets.
Click to reveal answer
beginner
How is INTERSECT different from UNION in SQL?
INTERSECT returns only rows common to both queries, while UNION returns all unique rows from both queries combined.
Click to reveal answer
intermediate
Can INTERSECT be used with queries that select different columns?
No, both queries must select the same number of columns with compatible data types for INTERSECT to work.
Click to reveal answer
beginner
Write a simple SQL query using INTERSECT to find common employee IDs from two tables: Employees2023 and Employees2024.
SELECT EmployeeID FROM Employees2023
INTERSECT
SELECT EmployeeID FROM Employees2024;
Click to reveal answer
intermediate
What happens if there are duplicate rows in the results of the SELECT queries used with INTERSECT?
INTERSECT automatically removes duplicates and returns only distinct common rows.
Click to reveal answer
What does the INTERSECT operator return in SQL?
✗ Incorrect
INTERSECT returns only the rows that appear in both SELECT query results.
Which condition must be true for two SELECT queries to be used with INTERSECT?
✗ Incorrect
Both queries must select the same number of columns with compatible data types for INTERSECT to work.
If one SELECT query returns duplicate rows, how does INTERSECT handle them?
✗ Incorrect
INTERSECT removes duplicates and returns only distinct common rows.
Which SQL operator would you use to find rows that appear in both tables?
✗ Incorrect
INTERSECT returns rows common to both tables.
What is the result of this query?
SELECT id FROM A
INTERSECT
SELECT id FROM B;
✗ Incorrect
The query returns IDs that exist in both tables A and B.
Explain in your own words what the INTERSECT operator does in SQL and when you might use it.
Think about comparing two lists and finding what they share.
You got /3 concepts.
Describe the difference between INTERSECT and UNION in SQL with an example scenario for each.
Consider when you want only shared data vs all data combined.
You got /3 concepts.