MYSQL 两个表关联查询_MySQL
程序员文章站
2022-05-01 16:30:00
...
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的别名。这样当名字很长时比较好用。
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的别名。这样当名字很长时比较好用。
上一篇: jQuery实现追加数组并去重功能
下一篇: oracle官文之与网络配置相关的文档