Monday, November 05, 2007

SQL UNION and UNION ALL

UNION

The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type.

UNION ALL

The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

Use "union all" when u wan all data for sql1 & sql2.
:)
"union" sometime might cause data missing if data from sql1 & sql2 are same.

ref

No comments: