The syntax of the UNION statement is the following:
SELECT_Query_1
UNION [ALL]
SELECT_Query_2
The purpose of the SQL UNION command is to combine the results of two queries together. UNION is somewhat similar to the JOIN command in that they are both used to related information from multiple tables. This command does have some restrictions. One restriction of UNION is that all corresponding columns need to be of the same data type. Also, when using UNION, only distinct values are selected similar to SELECT DISTINCT. Also, each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types and all of the columns in each SELECT statement must be in the same order. There is also a UNION ALL command (Rob and Coronel (2009). 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 is as follows:
[SQL Statement 1]
UNION [ALL]
[SQL Statement 2] (SQL Book)
Another helpful SQL command is INTERSECT. Similar to the UNION
References: Rob, P., & Coronel, C. (2009). Database Systems Design, Implementation, and Management (8th ed.). Boston, MA: Thomson Course Technology. SQL Book. Retrieved from http://www.sqlbook.com/SQL/SQL-UNION-and-UNION-ALL-32.aspx BLACK WASP. Retrieved from http://www.blackwasp.co.uk/SQLExceptIntersect.aspx