Recall & Review
beginner Click to reveal answer
What does the SQL UNION operator do?
UNION combines the results of two or more SELECT queries into a single result set, removing duplicate rows.
beginner Click to reveal answer
How does UNION ALL differ from UNION?
UNION ALL combines results from multiple SELECT queries but keeps all duplicates, showing every row from all queries.
intermediate Click to reveal answer
Can you use UNION or UNION ALL with SELECT queries that have different numbers of columns?
No, all SELECT queries combined with UNION or UNION ALL must have the same number of columns with compatible data types.
intermediate Click to reveal answer
Why might you choose UNION ALL over UNION in a query?
Use UNION ALL when you want to keep duplicates and improve performance because it does not check for duplicates like UNION does.
beginner Click to reveal answer
What happens if you use UNION on two queries that return the same rows?
UNION will show each row only once, removing duplicates from the combined result.
Which SQL operator removes duplicate rows when combining results?
✗ Incorrect
UNION removes duplicates, while UNION ALL keeps all rows including duplicates.
If you want to combine results and keep all duplicates, which should you use?
✗ Incorrect
UNION ALL keeps all rows including duplicates.
What must be true about the SELECT statements combined with UNION or UNION ALL?
✗ Incorrect
All SELECT queries combined must have the same number of columns and compatible types.
Which operator is generally faster because it does not remove duplicates?
✗ Incorrect
UNION ALL is faster because it skips the duplicate removal step.
What will the result of UNION be if two queries return identical rows?
✗ Incorrect
UNION removes duplicates, so only one copy of each identical row appears.
Explain the difference between UNION and UNION ALL in SQL.
Think about how duplicates are handled and performance.
You got /4 concepts.
What are the requirements for SELECT statements when using UNION or UNION ALL?
Consider the structure of the SELECT queries.
You got /3 concepts.
