Showing posts with label unionAll. difference between Union and UnionAll. Show all posts
Showing posts with label unionAll. difference between Union and UnionAll. Show all posts

Monday, August 9, 2010

union vs unionAll

There is a difference between Union and UnionAll for UnionType enum. Here is the simple example of UnionAll and Union.

lets suppose we have two sets (tables).
A = {a, b, c, e, f}, B = {g, h, i, j, k, f, c}

In the example above you can see 'f' and 'c' are common in both sets.

So, If we take Union the result would be

A Union B = {a, b,c, e, f, g, h, i, j, k}

Here you can see nothing is repeated but if we take UnionAll it will repeat both in a result set.

A UnionAll B = {a,b,c,e,f,g,h,i,j,k,f,c}