条件查询
distinct:表示去重,去除重复的数据
select distinct name from student;
like:模糊查询,模糊查询数据
select * from emp where name like "%a" //以a结尾
select * from emp where name like "a%" //以a开头
select * from emp where name like "%a%" //a在中间
null:过滤
select * from emp where name is null;
select * from emp where name is not null;
between and:包含关系 [1000,3000]
select * from emp where sal >=1000 and sal<=3000;
select * from emp where sal between 1000 and 3000;
limit
select * from emp limit 3; //查询前3行
select * from emp limit 1,2 //从第2行开始,查询2行
order by
select * from emp order by sal// //默认升序
select * from emp order by sal desc;//降序
聚合函数
count(累加) max(最大值) min(最小值) sum(总和) avg(平均值)