Consider two tables 'A' and 'B'. What does the following query do?
SELECT * FROM A
INTERSECT
SELECT * FROM B;
Consider two tables 'A' and 'B'. What does the following query do?
SELECT * FROM A
INTERSECT
SELECT * FROM B;
Solution
✅ Correct Option: 1
INTERSECT returns only the rows that appear in the results of both SELECT statements. Here, it gives the rows of A that also exist in B, with duplicates removed.
Option 2: that is what UNION (or UNION ALL) does, combining the rows of both tables.
Option 4: that is what EXCEPT (MINUS in Oracle) does, returning rows of A that are not in B.
Both queries in an INTERSECT must have the same number of columns with compatible data types.
Related questions:
2026: 23 May Shift 1
2026: 23 May Shift 2