SQL TutorialLesson 33Free preview
SQL Union All
This lesson is part of SQL · All levels
Summary
UNION ALL incorporates the query results exactly like UNION, but maintains a duplicate line. Since there is no need to check duplicates, UNION ALL is generally faster. Use UNION ALL if duplicate is not a problem or is actually needed.
Key points
- Union All is union without duplicate deletion.
- It's usually faster because it goes through the process of deduplication.
- The resulting line number is the total line of all queries combined.
- It's a good idea to combine period data that's definitely not overlapping.
- UNION is usually used when unique results are needed.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.