SQL “Union ALL” vs. “Union”

Email This Page | Print This Page | Go Back


1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Sometimes, you might need to get a record set of the UNION of two SELECT’s but you don’t want to remove duplicates.  This might happen if you were just needing a proper count of the rows or if you just wanted to check something before deleting a bunch of rows.

The simple way to do this is with UNION ALL.

A UNION statement returns the UNION of two SELECT’s but removes duplicates.  If you use UNION ALL, the records returned are all the records including duplicates.

Share Is Caring:
  • Digg
  • Facebook
  • Google
  • LinkedIn
  • MySpace
  • StumbleUpon
  • Technorati
  • TwitThis
Go Back


Rate This Article

Leave a Reply