0
how to use the union function
how to use the union function
2 Réponses
+ 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;
+ 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 |