1、带where关键字的查询,where后面带条件语句(<,>,>=,<=,=,<>)
Select * from student where id=1;
Select * from student where age>15;
2、like使用占位符_和%,_代表一个字符,%代表任意个字符。
Select * from student where name like %新%;
3、in关键字
Select * from student where id in(2.3,6);
4、or关键字
Select * from student where id=1 or id=3 or id=5;
5、and关键字
Select * from student where id>3 and age>5;
6、not关键字
Select * from student where not(id>100);
7、is null 判断是否为空
8、Between .... and ... 显示在魔衣区间的值(含头含尾)
9、排序查询(order by——asc升序,desc降序)
Select * from student order by age asc;
条件加排序(order by 必须放在条件后面)
Select * from student where name like ‘喻%’ order by age desc;
10、聚合函数
常用:sum()求和、avg平均、min()最小、count()计数;
注意:集合函数不统计null值
11、分组查询(ground by)
Select age count(*) from student ground by age;
注意:用ground by后条件要用having,不可以用where
Select age count(*) from student ground by age having count(*)>3;
12、查询语句关键字排序
Select-->from-->where-->group by-->having-->order by(必须放在最后)
13、limit关键字(分页查询 )
Select * from student limit(6,3);