Recall & Review
beginner
What does the UNION operator do in SQL?
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 each query.
Click to reveal answer
intermediate
Can UNION be used 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?
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 duplicate row only once, removing any repeated rows 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.
What must be true about the SELECT statements combined with UNION or UNION ALL?
✗ Incorrect
All SELECT statements combined with UNION or UNION ALL must have the same number of columns and compatible data types.
Which operator is faster when you don't need to remove duplicates?
✗ Incorrect
UNION ALL is faster because it does not check for duplicates.
If two SELECT queries return the same row, how many times will it appear in the result of UNION ALL?
✗ Incorrect
UNION ALL includes all rows, so duplicates appear as many times as they occur.
Which SQL operator combines results but does not remove duplicates?
✗ Incorrect
UNION ALL combines results and keeps duplicates.
Explain the difference between UNION and UNION ALL in SQL.
Think about how duplicates are handled and when you might want to keep them.
You got /4 concepts.
What rules must SELECT queries follow to be combined using UNION or UNION ALL?
Focus on the structure of the SELECT statements.
You got /4 concepts.