Normally
when you execute SELECT statements, you are dealing with sets of data. There
are some set operations that can work on two different sources (e.g. tables).
One of the most common operations is UNION. If you UNION two data sets, you
will get all data from the two sets, with duplicates removed.
There are
some restrictions in place when you perform a union. The data types in each
column of the two sources must be comparable. If the data types are comparable
but different, the bigger data type is produced in the UNION result. The names
of the columns are the names from the first source used. The order of output is
not guaranteed.
If you want
to do a UNION, but want to preserve the duplicates in the output, you can
perform a UNION ALL. This is faster than the UNION that removes the dups. If
you want to order the results of the UNION, the ORDER BY must be placed after
the second query.
There are other operations in addition to UNION.
EXCEPT will give you results from the first query that are not in the second.
INTERSECT will give you results that are only in both queries.