Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

UNION

UNION

The UNION command merges the result sets of two or more SELECT statements, considering only distinct values.

The provided SQL statement retrieves the cities (only distinct values) from both the “Customers” and the “Suppliers” table:

Example

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