0

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.

2 Answers 2

2

You are looking for full join:

select t2.a, t1.b
from t1 full join
     t2
     on t1.a = t2.a;
Sign up to request clarification or add additional context in comments.

Comments

0

Full outer join:

SELECT t2.a,
  t1.b
FROM table1 t1
FULL OUTER JOIN table2 t2
ON t1.a = t2.a

For more:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.