如果您加入表B,表C等,如何返回表A中的所有行,并且每个连接的表可能没有匹配的记录?
示例:
Table A Table B Table C
Row Letter Row Shelter Row Food
1 A 1 House 1 Bread
2 B 2 Shed 2 Cheese
3 C 3 Tent 3 Meat
4 D 4 Patio
5 E
结果
Row Letter Shelter Food
1 A House Bread
2 B Shed Cheese
3 C Tent Meat
4 D Patio
5 E
我的查询会根据每个没有匹配值的表来减少结果,这意味着该项目不存在任何条目。
答案 0 :(得分:0)
使用Outer Joins
select *
From TableA a
Left Join TableB b on a.Row = b.Row
Left Join TableC c on a.Row = c.Row
左连接将带来左表中的所有记录,即使右表中没有匹配的记录