I have two tables A and B, Table A have 3 cols and table B have 2 cols.
Table A data:
| name | id | city |
|---|---|---|
| xyz | 1 | ab |
| xyz2 | 2 | ab1 |
| xyz3 | 3 | ab2 |
Table B data:
| name | id |
|---|---|
| xyz3 | 3 |
| abc2 | 4 |
Output I want:
| name | id | city | match |
|---|---|---|---|
| xyz | 1 | ab | no |
| xyz2 | 2 | ab1 | no |
| xyz3 | 3 | ab2 | yes |
| abc2 | 4 | NULL | no |
I have tried this but it is giving op in different column:
select *
from TableA a
full outer join TableB b
on a.id= b.id
Output I'm getting
| name | id | city | name | id |
|---|---|---|---|---|
| xyz | 1 | ab | null | null |
| xyz2 | 2 | ab1 | null | null |
| xyz3 | 3 | ab2 | xyz3 | 3 |
| Null | null | null | abc2 | 4 |
Output I want:
| name | id | city | match |
|---|---|---|---|
| xyz | 1 | ab | no |
| xyz2 | 2 | ab1 | no |
| xyz3 | 3 | ab2 | yes |
| abc2 | 4 | NULL | no |