Difference Between Union And Union All?
Answers (1)
Add AnswerUNION: It merges the results of many tables into a single result set and returns distinct records.
UNION ALL: It merges the results from many tables into a single result set and returns all of the records.
Example :
SELECT name FROM Students /* Fetch the union of queries */ UNION SELECT name FROM Contacts; SELECT name FROM Students /* Fetch the union of queries with duplicates*/ UNION ALL SELECT name FROM Contacts;