多表LEFT JOIN中左右表判定——以Country、city、customer表为例
LEFT JOIN 表关系解析
先看执行的SQL语句:
SELECT country.country_name_eng, city.city_name, customer.customer_name FROM Country LEFT JOIN city ON city.country_id = country.id LEFT JOIN customer ON customer.city_id = city.id
针对问题逐一解答:
- city表的左表:
Country表 - Country表的右表:
city表 - customer表的左表:是
Country和city做左连接后的结果集(若仅看直接关联的基础表,也可理解为city表) - customer表的右表:无,该查询中customer是最后一次JOIN的右表,后续没有关联其他表
内容的提问来源于stack exchange,提问作者Sudarshan Patil
相关产品推荐
相关产品推荐

