In SQL, UNION keyword does nothing more than mash the output of two or more queries together into one big result set. UNION requres the queries to have the same number of columns. Second, the columns should have compatible data type and size, but some query engines are flexible on this strict ANSI requirement. Third, the columns must have the same constraints with regard to null values. Either both columns must allow nulls or forbid nulls. Again, some products are less strict than the standard. Last, UNIONs may not be subqueries, nor may they have aggregate functions. Check your product's documentation for details.

Here is what one looks like:

   SELECT name, email, phone_number FROM salespeople


   SELECT name, email, phone_number FROM engineers;
And the output might look like:
Jones, Jim      123-123-1234
Sousa, Sam      123-123-1235
Dilbert, J        234-234-1234
Smart, Alec        234-234-2344

There are no column headings on purpose in the output example above. Since the column names are often different in the SELECT statements comprising the UNION, the query engine cannot know what to call the columns so quite often there are no column names in the output. Remember, the columns must be of the same type and size, but there is no requirement that their data be in any way related. You really can mix apples and oranges with a UNION query.

One important "gotcha" with UNION is that by default it eliminates duplicate rows in each SELECT statement (see DISTINCT). To ensure each row gets returned, UNION ALL must be used.