The UNION Operator
In set theory, the union of two sets (call them A and B) is the set containing all elements of both A and
B. In other words, if an element belongs to any of the input sets, it belongs to the result set. Figure 6-1
shows a set diagram (also known as a Venn diagram) with a graphical depiction of the union of two
sets. The shaded area represents the result of the set operator.
Union: A U B
A
B
FIGuRE 6-1
A union of two sets.
In T-SQL, the UNION operator unifies the results of two input queries. If a row appears in any of
the input sets, it will appear in the result of the UNION operator. T-SQL supports both the UNION ALL
and UNION (implicit DISTINCT) flavors of the UNION operator.
Do'stlaringiz bilan baham: |