Skip to content

UNION

SELECT country FROM Suppliers
UNION
SELECT country FROM Customers;
+-----------+
| country |
+-----------+
| Germany |
| USA |
| Japan |
| France |
| UK |
| Australia |
+-----------+

The UNION operator is used to combine the result-set of two or more SELECT statements. Each SELECT statement within the UNION must have the same number of columns, the columns must also have similar data types, and the columns in each SELECT statement must also be in the same order. In this example, we’re selecting country from two different tables: Suppliers and Customers. The resulting output is a list of countries from both tables, without any duplicate entries.