UNION ALLcommand is also to combine the results of two queries together, and UNION ALLselects all values.
The purpose of the SQL UNION ALLcommand is also to combine the results of two queries together. The difference between UNION ALL andUNION is that, while UNION only selects distinct values, UNION ALLselects all values.
The syntax for UNION ALL is as follows:
[SQL Statement 1]
[SQL Statement 2]
Let’s use the same example as the previous section to illustrate the difference. Assume that we have the following two tables,
and we want to find out all the dates where there is a sales transaction at a store as well as all the dates where there is a sale over the internet. To do so, we use the following SQL statement:
SELECT Date FROM Store_Information
SELECT Date FROM Internet_Sales