模糊查询
模糊查询时——字段名 like
%一个或者多个字符,可能有可能没有
_任意一个字符
select * from 表名 where name like ‘%昭%’
查找
查找表格中名字含有昭的所有信息
排序
对查找到的内容进行排序
select * from 表名 order by salary
默认升序
select * from 表名 order by salary asc ——————升序
select * from 表名 order by salary desc ——————降序
首要排序条件 次要排序条件
select * from 表名 order by salary desc,id desc
分组查询
聚合函数
count(*
)——根据条件查询到有多少条记录,包含数据为null
coount(字段名)——根据条件查询到有多少条记录,不包含数据为null
select departid,count(*
) as 员工数 from 表名 group by departid
select sex,count(*
) as 总数 from 表名 group by sex
select departid,sum(salary) as 发工资总数 from 表名 group by departid