How add two or more tables?

Viewed 31

Postgresql

I have two tables:

Tables:

A:

|---------------------|
|        Number1      |
|---------------------|
|          12         |
|---------------------|

B:

|---------------------|
|        Number2      |
|---------------------|
|          32         |
|---------------------|

How write 'select' query which result will be:?

|---------------------|------------------|
|        Number1      |       Number2    |
|---------------------|------------------|
|          12         |                  |
|---------------------|------------------|
|                     |         32       |
|---------------------|------------------|

I read about 'join' and 'union', but I didn't find solution.

1 Answers

You need UNION ALL:

SELECT Number1, NULL Number2 FROM A
UNION ALL
SELECT NULL, Number2 FROM B
Related