【发布时间】:2019-03-04 15:49:31
【问题描述】:
table1
out_path_id
in_path_id
other_fields
table2
id
name
location_to_id
location_from_id
car_id
other_fields
位置
id
name
汽车
id
name
table1的out_path_id和in_path_id是指table2的id。
table2的location_to_id和location_from_id是指location的id。
table2的car_id是指car的id。
可以加入table1和table2。
select t2out.name out_name, t2in.name in_name, t1.other_fields
from table1 t1
join table2 t2out on t2out.id=t1.out_path_id
join table2 t2in on t2in.id=t1.in_path_id
现在我尝试继续加入location 和car。我能做些什么?
【问题讨论】:
-
请更新描述以显示您期望结果集的样子;这是了解连接应该如何工作的必要条件。