Consider two tables 'A' and 'B' having some common rows. What does the following query return?
SELECT * FROM A
UNION
SELECT * FROM B ;
Consider two tables 'A' and 'B' having some common rows. What does the following query return?
SELECT * FROM A
UNION
SELECT * FROM B ;
Solution
✅ Correct Option: 4
UNION combines the result sets of the two SELECT statements and removes duplicates. Every row that is in A, in B, or in both appears in the output, and each common row is shown only once.
Option 1: this describes INTERSECT, not UNION.
Options 2 and 3: these describe joins (like a left or right join), which keep all rows from one table and only matching rows from the other.
UNION ALL is the version that keeps duplicate rows, so common rows would appear twice.
Related questions:
2025: 14 May Shift 1
2025: 13 May Shift 2
2025: 13 May Shift 2
2025: 20 May Shift 1