The following SQL statement returns 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;
UNION
SELECT City FROM Suppliers
ORDER BY City;
Note: If some customers or suppliers have the same city, each city will only be listed once, because UNION
selects only distinct values. Use UNION ALL
to also select duplicate values!
Practice Excercise Practice now