您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

MYSQL 两个表关联查询_MySQL

2024/4/14 10:13:54发布10次查看
select
states.state_id,
states.state_name,
cities.city_id,
cities.city_name,
cities.region_id
from states
inner join cities
on states.state_id=cities.state_id
where states.countrycode=”counttrycode“;
也可以使用别名:
如下:
select
s.state_id,
s.state_name,
c.city_id,
c.city_name,
c.region_id
from states s
inner join cities c
on s.state_id=c.state_id
where s.countrycode=”counttrycode“; 
s 是states的别名, c是cities的别名。这样当名字很长时比较好用。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product