学习参考https://www.bilibili.com/video/BV1Kr4y1i7ru?spm_id_from=333.999.0.0
目录

一.基本查询

(1)查询多个字段
(1)查询指定字段
select name,workno,age from employee;

(2)查询所有字段
select *from employee;
select 所有字段 from employee;

(2)设置别名
select workaddress as ‘别名’ from employee;
select workaddress ‘别名’ from employee;

(3)去除重复记录
select distinct workaddress as ‘工作地址’ from employee;

二. 条件查询
select 字段||* from 表 where 条件
三.聚合函数

#统计数量-------------------------
select cout(*) from 表;
select cout(字段) from 表;
#统计平均数-----------------------
select avg(字段) from 表;
#统计平均数-----------------------
select avg(字段) from 表;
#找最小值-------------------------
select min(字段) from 表;
#找最大值-------------------------
select max(字段) from 表;
#求和-----------------------------
select sum(字段)from 表;
------------------------------------------
select 聚合函数(字段)from 表 where 条件;
四.分组查询

#根据字段1进行分组,统计字段二XXXXXX.
select 字段1, 聚合函数(字段2) from 表 group by 字段1;
五.排序查询

select * from 表 order by 字段 排序方式;
六.分页查询

select * from 表 limit 起始页, 记录数;
#如果是第一页的话
select * from 表 limit 几条记录;
select* from 表 limit ((第几页-1)*记录数) ,记录数;

七.执行顺序和编写顺序
(1)编写顺序

(2)执行顺序


395

被折叠的 条评论
为什么被折叠?



