'Join all record even not match
I have tables_1 and table_2
table_1
id name cost
100 joe 10
101 bob 20
102 mary 30
table_2
id name
100 joe
101 bob
102 mary
103 tom
I want to join these tables even no match id and expect result
id name cost
100 joe 10
101 bob 20
102 mary 30
103 tom null
My query
select t1.id, t1.name, t1.column1, t1.column2
from Table_1 t1
join Table_1 t2 on t1.id = t2.id
and t1.id <> t2.id
I got nothing return. Need some help. Thank you
Solution 1:[1]
It looks like you need a simple outer join
select t2.id, t2.name, t1.cost
from table_2 t2
left join table_1 t1 on t1.id=t2.id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stu |
