Though both UNION and UNION ALL is used to combine results of two SELECT queries, main difference between them is that UNION doesn’t include duplicate record but UNION ALL does.

Both UNION and UNION ALL concatenate the result of two different SQLs. They differ in the way they handle duplicates.

  • UNION performs a DISTINCT search on the result set, eliminating any duplicate rows.
  • UNION ALL does not remove duplicates, and it therefore faster than UNION.

union  union_usingunionallunionall_using

SQL Union and Union ALL – The difference you should know

Leave a Reply

Your email address will not be published. Required fields are marked *