Wednesday, December 26, 2012

Difference Between UNION and UNION ALL in SQL


UNION

Combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union.

Basic rules for using UNION: 

·         The number and the order of the columns must be the same in all queries.
·         The data types must be compatible

UNION ALL 

Incorporates all rows into the results. This includes duplicates.
If not specified, duplicate rows are removed.

No comments:

Post a Comment