mysql入门-lesson04

任务目标-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;

课程视频

bilibili lesson4
xigua lesson4

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容