Guys welcome to DB2 SQL. There are mostly used popular set operators. These set operators you always need to keep handy especially on how to use in your SQL while writing Queries for your project.
- Union all
And how to use multiple operators is also you need to learn. In my previous post I have explained the real use of these operators.
Before going in detail about all operators, I am giving here some good comparison on UNION Vs UNION ALL
How to Use UNION
The simple UNION is the same operator you had in high school set theory; it returns the rows that appear in either or both tables and removes redundant duplicates from the result table.
(SELECT a1 FROM S1 UNION SELECT a2 FROM S2);
How to Use UNION All
The UNION ALL preserves the duplicates from both tables in the result table.
(SELECT a1 FROM S1 UNION ALL SELECT a2 FROM S2)