Which condition must be true for two SELECT statements to be combined using UNION in SQL?
easy📝 Conceptual Q1 of 15
SQL - Set Operations
Which condition must be true for two SELECT statements to be combined using UNION in SQL?
ABoth SELECT statements must have identical column names.
BBoth SELECT statements must have the same number of columns with compatible data types.
CBoth SELECT statements must use the same WHERE clause.
DBoth SELECT statements must select from the same table.
Step-by-Step Solution
Solution:
Step 1: Understand the requirement for UNION
UNION combines results vertically, so columns must match in number and type.
Step 2: Check each option against the rule
Only Both SELECT statements must have the same number of columns with compatible data types. states the correct rule about column count and compatible types.
Final Answer:
Both SELECT statements must have the same number of columns with compatible data types. -> Option B
Quick Check:
Set operation column matching = D [OK]
Quick Trick:UNION needs same column count and compatible types [OK]
Common Mistakes:
MISTAKES
Assuming tables must be the same
Believing WHERE clauses must match
Thinking column names must be identical
Master "Set Operations" in SQL
9 interactive learning modes - each teaches the same concept differently