UNION
The UNION command is used to select related information from two tables,
which is like a JOIN command. However, when using UNION command, all the
selected columns need to be of the same data type. With UNION, only distinct
values are selected.
UNION ALL
UNION ALL command is equal to UNION command, except that UNION ALL selects all
the values.
The difference between Union and Union all is that Union all will not eliminate
duplicate rows, instead it just pulls all the rows from all the tables fitting
your query specifics and combines them into a table.
A UNION statement effectively does a SELECT DISTINCT on the results set.
If you know that all the records returned are unique from your union,
use UNION ALL instead, it gives faster results.
SELECT column1, Column2 ...Column (N) FROM tableA
UNION
SELECT column1, Column2 ...Column (N) FROM tableB;
SELECT column1, Column2 ...Column (N) FROM tableA
UNION ALL
SELECT column1, Column2 ...Column (N) FROM tableB;