Follow these guidelines when using UNION operators:
For example, two tables contain:
table3 |
table4 |
|||
a |
b |
c |
a |
b |
int |
char(4) |
char(4) |
char(4) |
float |
--- |
------- |
------- |
------- |
------- |
1 |
abc |
jkl |
jkl |
1.000 |
2 |
def |
mno |
mno |
5.000 |
3 |
ghi |
pqr |
Execute this query:
SELECT a, b FROM table3
UNION
SELECT b, a FROM table4
Here is the result set:
a b
-------- -----
1.000000 abc
2.000000 def
3.000000 ghi
1.000000 jkl
5.000000 mno
This query produces an error message because the data types of corresponding columns are not compatible:
SELECT b, c FROM table3
UNION
SELECT a, b FROM table4
SELECT city AS Cities FROM stores_west
UNION
SELECT city FROM stores_east
ORDER BY city
UNION |