What is the difference between UNION and UNION ALL?

PointUNIONUNION ALL
DuplicatesRemovedKept
SpeedSlower (has to find duplicates)Faster
SELECT city FROM students
UNION
SELECT city FROM students;       -- 4 rows

SELECT city FROM students
UNION ALL
SELECT city FROM students;       -- 12 rows

Both queries must have the same number of columns. See MySQL UNION.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.