I couldn't figure out how to join these two tables and get the result with NULL value that I want. I played around with LEFT JOIN
, RIGHT JOIN
, FULL OUTER JOIN
..., but couldn't get it to work. Please see this below.
Table1:
NameID Name
1 N1
2 N2
3 N3
4 N4
5 N5
Table2:
NameID AnotherID Value
1 AID-111 1000
2 AID-222 2000
2 AID-222 3000
3 AID-333 4000
4 AID-444 5000
Select ...
JOIN Table1 and Table2
WHERE AnotherID = 'AID-222'
This is the result I want:
NameID Name AnotherID VALUE
1 N1 NULL NULL
2 N2 AID-222 2000
3 N3 AID-222 3000
4 N4 NULL NULL
5 N5 NULL NULL
Please help. Thanks!