where条件查询

1、常见的运算符
关系运算符:=、!=、<>、>= 、<=
区间:between A and B -》 [A,B]
And:并且,和
Or:或者
Is null:空
Not:否,非
Is not null:非空
In:在什么里面
2、或or、并且and
##(2.1)查询性别女,并且 年龄65的学生记录

select * from stu where gender ='female' and age = "65";

##(2.2)查询学号是S_1001或者名字为liSi的记录

select * from stu where sid = 'S_1001' or age = "65";

3、在什么里面in
##(2.3)查询学号是S_1001,S_1002,S1003的记录

写法一:select * from stu where sid = 'S_1001' or sid = 'S_1002' or sid = 'S_1003';
写法二:select * from stu where sid in('S_1001','S_1002','S_1003');

##(2.3)查询学号不是S_1001,S_1002,S_1003的记录

select * from stu where sid not in('S_1001','S_1002','S_1003');

4、是否为空is (not) null
##(2.4)查询年龄为空(null)的记录

select * from stu where age is null;

##(2.7)查询名字不为空的(not null)学生信息

select * from stu where sname is not null

5、区间between
##(2.5)查询年龄为20~40岁之间的
方式一:select * from stu where age >= 20 and age <=40;
方式二;select * from stu where age between 20 and 40;
6.非not
#(2.6)查询性别:非男的 学生记录

select * from stu where gender != 'male';

select * from stu where gender <> 'male';

select * from stu where not gender = 'male';
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值