MySQL Union operator


Example

The UNION operator is used to combine the result-set (only distinct values) of two or more SELECT statements.

Query: (To selects all the different cities (only distinct values) from the "Customers" and the "Suppliers" tables)

SELECT City FROM Customers
UNION
SELECT City FROM Suppliers
ORDER BY City;

Result:

Number of Records: 10

City
------
Aachen
Albuquerque
Anchorage
Annecy
Barcelona
Barquisimeto
Bend
Bergamo
Berlin
Bern