MYSQL 两个表关联查询_MySQL
- WBOYOriginal
- 2016-06-01 13:06:351300browse
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的别名。这样当名字很长时比较好用。
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn