Recall & Review
beginner
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.
Click to reveal answer
beginner
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.
Click to reveal answer
intermediate
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.
Click to reveal answer
intermediate
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.
Click to reveal answer
beginner
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.
Click to reveal answer
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.