MYSQL 两个表关联查询_MySQL
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的别名。这样当名字很长时比较好用。 |
- 上一篇:mac中安装mysql
- 下一篇:MySQL 更新并返回计数_MySQL