Which of the following is TRUE for union operation in SQL?
Which of the following is TRUE for union operation in SQL?
Solution
UNION combines the result sets of two SELECT statements and removes duplicate rows. A row present in both tables therefore appears only once in the output. (UNION ALL is the version that keeps duplicates.)
For UNION to work, both queries must return the same number of columns with compatible data types. The number of rows in the tables does not matter.
Option 1: the number of attributes (columns) must be the same, not different.
Option 3: only the column count and types must match; the number of rows can differ.
Option 4: getting common tuples is the job of INTERSECT, not UNION.
Related questions:
2025: 15 May Shift 2
2026: 29 May Shift 2
2025: 15 May Shift 2