单表查询
1.查询所有字段
select * from 表名
2.查询指定字段
select 字段1,字段2 from 表名
3.as
查询的结果中列名显示其他名字:
select 字段1 as 别名,字段2 as 别名 from 表名
4.条件查询
1)select * from 表名 where age >/< 10;
2)去点重复的字段
select distinct sex from 表名
3)in
select from 表名 where id (not)in (1,2,3)
4)between and
select * from 表名 where id between2 and 4
5)like 模糊查询
select * from 表名 where name like ‘%y’
%不限字数 _只能是一个字
6)and 满足所有条件 or满足任意条件
select * from 表名 where name=’’ and sex=’’
4.排序 asc(默认的 升序) desc(降序)
select * from 表名 order by age desc/asc
5.限量 limit
select * from 表名 limit(1,3)
6.聚合函数
max() min() avg() sum() count()