2.4

How to Code a UNION

How to Code a UNION

Code Example:

1 USE world;
2 SELECT name, population
3 FROM city WHERE CountryCode = 'AUS'
4 UNION
5 SELECT name, population
6 FROM country
7 WHERE continent = 'Oceania'
8 ORDER BY name; 

Results:

04_joins.png

SELECT name, population
FROM city
WHERE CountryCode = 'AUS'

UNION

SELECT name, population
FROM country
WHERE continent = 'Oceania'

ORDER BY name;

CC BY-NC-ND International 4.0

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.