数据过滤AND OR IN 操作符的说明与使用
操作符:
用来联结或改变WHERE子句中的子句关键词。也成为逻辑运算符。
1.AND(和)条件都需要满足
select order_name as 姓名,order_price as 价格 from order_list
where order_name='老六' AND order_price=55--只有满足两者条件才能检索出来
--也可以用于区间检索
select *
from order_list
where order_price>0 AND order_price<10 AND order_name='老六'--多个并列条件,多个and
2.OR(或) 条件满足一个就行
select *
from order_list
where order_price>5 OR order_name='老六'
3.in 指定条件范围
select *
from order_list
--where order_price=3 OR order_price=4
where order_price IN(3,4)
ORDER BY order_count desc--范围仅是价格为3和4的数据,作用于OR相同。当同一个列有多个指定条件时,使用IN更加方便。
4.NOT操作符 否定它之后所有跟的任何条件
select *
from order_list
where order_price NOT IN(3,4)
ORDER BY order_count