条件查询

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值