and 和 or 操作符
例
select prod_name ,prod_price
form products
where vend_id =1002 or vend_id=1003 and prod_price >=10; #这样会先处理 and部分的内容,再处理or的内容
例2
select prod_name ,prod_price
form products
where( vend_id =1002 or vend_id=1003) and prod_price >=10;
in 操作符
select prod_name , prod_price
form products
where vend_id in (1002,1003) #会与括号中的值逐个匹配,实际效果与 where vend_id = 1002 or vend_id=1003一样
order by prod_name;
not操作符
not操作符就是否定后面的任何条件
select prod_name , prod_price
form products
where vend_id not in (1002,1003)
order by prod_name;
时间: 2024-10-12 18:39:45