伙计们正在尝试使用LEFT JOIN从其他表中获取结果。 我想使用Join显示用户位置。
我的数据库如下所示:
用户表:
#ID | location_id | email | pass
------------------------------------
1 | 1 | ... | ....
Locataion表:
#ID | county_id | city_id | user_id
------------------------------------------
1 | 1 | 1 | 2
Coutnries表:
#ID | name |
-------------------
1 | Usa
2 | Belgium
3 | Serbia
城市表:
#ID | name |
-------------------
1 | Berlin
2 | London
3 | New Your
答案 0 :(得分:1)
试试这种方式
select * from usertable as a
join locataion as b on a.location_id=b.id
left join Coutnries as c on b.County_id = c.id
left join cities as d on b.City_id= d.id