select vend_id, prod_id, prod_price,prod_name from Products where vend_id='DLL01' and prod_price <=4;
2、or 操作符
or 前后的两个条件满足任意一个都被检索出来
select vend_id, prod_id, prod_price,prod_name from Products where vend_id='DLL01' or vend_id='BRS01';
3、求职顺序
or 和 and 的求值顺序:优先处理and,在处理or
(1)先处理and左右两边的过滤条件
select vend_id, prod_id, prod_price,prod_name from Products where vend_id='DLL01' or vend_id='BRS01' and prod_price>=10;
(2)括号的优先级最高
括号 > and > or
select vend_id, prod_id, prod_price,prod_name from Products where (vend_id='DLL01' or vend_id='BRS01') and prod_price>=10;
4、in 操作符与or相同功能
(1)用法
in 操作符用来指定查询范围,范围内每一个都可以匹配。
in 取一组由逗号分隔,括在括号中的合法值。
select vend_id,prod_id,prod_price from Products where vend_id in ('DLL01','BRS01') order by prod_name;
(2)in 优点
①在有很多合法选项是,in 操作符份语法更清楚,更直观
②在于其他and 和 or 操作符组合使用in 时,求值顺序更容易管理
③in 操作符一般比一组 or 操作符执行更快
④in 最大的优点是可以包含其他 select 语句,能够更动态地建立where语句
5、not 操作符
只有一个功能,否定其后所跟的任何条件,可放在过滤列前也可在其后
select vend_id,prod_name from Products where not vend_id='DLL01' order by prod_name;
mysql基本操作(3)
演示数据下载地址:http://knowledge.zzhgod.com/file/mysql数据库文件.zip
mysql