mysql -uroot -p123 < world.sql # 常用用法 select countrycode,district from city; # 常用用法 select countrycode from city; # 查询单列 select countrycode,district from city limit 2; select id,countrycode,district from city limit 2,2; # 行级查询 select name,population from city where countrycode='CHN'; # 条件查询 select name,population from city where countrycode='CHN'and district='heilongjiang'; # 多条件查询 select name,population,countrycode from city where countrycode like'%H%' limit 10; # 模糊查询 select id,name,population,countrycode from city orderby countrycode limit 10; # 排序查询(顺序) select id,name,population,countrycode from city orderby countrycode desc limit 10; # 排序查询(倒序 desc 正序 asc) select*from city where population>=1410000; # 范围查询(>,<,>=,<=,<>) select*from city where countrycode='CHN'or countrycode='USA'; # 范围查询OR语句 select*from city where countrycode in ('CHN','USA'); # 范围查询IN语句 select country.name,city.name,city.population,country.code from city,country where city.countrycode=country.code and city.population <100; # 多表查询