测试必备的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;
原文:https://www.cnblogs.com/poloyy/p/12859861.html