1.什么时候用多表连接:
例如:查询世界人口小于100人的城市 所在国家的国土面积
想查询的内容 单张表无法满足 但 多张表有相同联系时 就可以用到连表查询
匹配相同的列 以这个列为契合点 把两张表连在一起 成为意义上的一张表
查询世界人口小于100人的城市
select * from city where population<100;
查询世界人口小于100人的城市 所在国家的国土面积
desc country;
2.怎么去多表连接查询
传统链接:基于where条件
1.找到表与表之间的关系列
2.排列查询条件
select name,countrycode from city where population<100;
找出PNC
select name,surfacearea from country where code='PCN'
上述两条命令合成一个
select city.name,country.name ,country.surfacearea
from city,country
where city.countrycode = country.code and city.population<100;
1.什么时候用多表连接:1.什么时候用多表连接:
网友评论