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]
[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
Next: SQL Inline View
|| Copyright © 2013 1keydata.com All Rights Reserved.