Reputation: 607
I have two tables inside PostgreSQL that I want to combine. They look like this:
A B -------- a 0 b 1 c 2
A --- a b d
I want to result of the "combine" operation to look like the following:
A B -------- a 0 b 1 - 2 d -
How do I accomplish this in postgres and also pure SQL? It seems that none of the JOIN
operations quite accomplish this.
Upvotes: 0
Views: 63
Reputation: 39457
Full outer join:
SELECT t2.a,
t1.b
FROM table1 t1
FULL OUTER JOIN table2 t2
ON t1.a = t2.a
For more:
Upvotes: 0
Reputation: 1269443
You are looking for full join
:
select t2.a, t1.b
from t1 full join
t2
on t1.a = t2.a;
Upvotes: 2