0

how to use the union function

how to use the union function

31st Oct 2016, 3:30 PM
Nelson Oguzie
Nelson Oguzie - avatar
2 Respostas
+ 2
The SQL UNION operator combines the result of two or more SELECT statements. A simple example for you: SELECT City, Country FROM Customers WHERE Country='Germany' UNION ALL SELECT City, Country FROM Suppliers WHERE Country='Germany' ORDER BY City;
31st Oct 2016, 3:49 PM
Shovan Lal Saha
Shovan Lal Saha - avatar
+ 1
Union combines two tables into one by just putting them one after the other. In general, the two tables you are trying to union need to have the same amount of columns. For example: | A | B | ====== | 1 | 2 | | 3 | 4 | unioned with | C | D | ====== | 5 | 6 | | 7 | 8 | gives the result | A | B | ====== | 1 | 2 | | 3 | 4 | | 5 | 6 | | 7 | 8 |
31st Oct 2016, 4:21 PM
Schindlabua
Schindlabua - avatar