SQL Union All
The purpose of the SQL UNION ALL command is also to combine the results of two queries together. The difference between UNION ALL and UNION is that, while UNION only selects distinct values, UNION ALL selects all values. The syntax for UNION ALL is as follows:
[SQL Statement 1]
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. To do so, we use the following SQL statement:
SELECT Date FROM Store_Information
Result:
|