任务目标-sql基本查询
学习sql基本语句where,group by,having,order by,limit
知识点
- select
- where
- group by
- having
- order by
- limit
上手操作
-- select 有趣应用
select @@basedir;
select @@datadir;
select @@innodb_buffer_pool_size;
select 134217728/1024/1024;
select 1+1;
select user();
select schema();
select now();
-- select 常规使用-from
select * from t1;
select id,name from t1;
-- 导入world.sql
set sql_log_bin=0;
source world.sql;
set sql_log_bin=1;
--select -where
select * from city where countrycode='chn';
--select -group by
-- count,min,max,sum,avg
select district,sum(population) from city where countrycode='chn' group by district;
--select -having
select district,sum(population) from city where countrycode='chn' group by district having sum(population)>1000000;
--select -order by limit
select district 省份,sum(population) 总人口 from city where countrycode='chn' group by 1 order by 2 desc limit 3;