select name,age,id,sex from student
select * from student
-- =等于
-- >大于
-- <小于
-- >=大于等于
-- <=小于等于
-- != <>不等于
select * from student where age>20
select * from student where sex="男"
-- 逻辑运算符
-- and 并且
-- or 或者
-- not 取非,主要用在in
select * from student where age>20 or sex="男"
-- 关键字
-- between...and...两个值之间 []
-- in 包含
-- is null 为null
select * from student where age between 20 and 24
select * from student where age not in(10,21,25)
select * from student where age is null
delete from student where id in(3,13)
-- 模糊查询
-- like 表示模糊查询,需要配合占位符进行使用
-- 占位符 _表示一位字符 %代表任意位字符
select * from student where name like "_李%"
-- 分页查询
-- limit 限制查询子语句
-- limit a,b a表示起始索引值 索引值从0开始 b代表查询个数
-- limit b offset a
select * from student limit 5,3
-- page当前是第几页 pageSize一页大小
select * from student limit (page-1)*pageSize,pageSize
select * from student where age >21 limit 1,2
-- 排序
-- order by 列名 desc降序|asc升序 asc可以省略
-- 排序子语句相对位置在where子语句之后,limit子语句之前
select * from student order by age
select * from student where age>20 order by age desc limit 0,2
-- 聚合函数|分组函数
-- sum 求和
-- avg 求平均
-- max 取最大值
-- min 取最小值
-- count 取得记录数
-- count(*)表示当前查询表中所有记录的个数
-- count(字段名称)不会统计为Null的记录
select count(*) from student
-- group by 字段名称
select max(age),classid from student group by classid