Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question