测试必备的Mysql常用sql语句系列
https://www.cnblogs.com/poloyy/category/1683347.html
WHERE 查询条件
本篇只讲比较运算符、逻辑运算符,其他会在后面篇幅讲解哦
这里有个重点,当运算符混合使用时,需要关注它们的优先级,具体可参考这篇博文:(后面补充)
一般单一条件查询用的就是比较运算符
select * from yyTest where id = 1;
select * from yyTest where id != 1;
select * from yyTest where height > 170;
select * from yyTest where height >= 175;
select * from yyTest where age < 20;
select * from yyTest where age <= 20;
多条件的查询都需要使用逻辑运算符,下面的栗子比较简单不展开描述
select * from yyTest where sex = 1 and height >175;
select * from yyTest where sex = 1 && height >175;
select * from yyTest where height < 165 or height >175;
select * from yyTest where height < 165 || height >175;
查询 age 小于 21,并且 height 小于 165 的学生信息和 age 大于 21,并且 height 小于等于 165 的记录
select * from yyTest where age < 21 xor height >= 165;
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有