ProAnswers.org

What is the difference between UNION and UNION ALL ?

What is the difference between UNION and UNION ALL ?

UNION ALL selects all records between two queries including duplicates, whereas

UNION takes the time to sort records in order to remove duplicates. In short UNION only selects distinct values, UNION ALL selects all values.

e.g.

SELECT Date FROM table1 UNION SELECT Date FROM table2

SELECT Date FROM table1 UNION ALL SELECT Date FROM table2