您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

oracle中and和or的区别是什么

2025/8/18 9:14:20发布20次查看
区别:1、在用于筛选条件时,and的意思是“与”,必须要所有条件都成立时返回为true,而or的意思是“或”,只要有一个条件成立就会返回true;2、and的优先级大于or。
本教程操作环境:windows10系统、oracle 11g版、dell g3电脑。
oracle中and和or的区别是什么1.and表示交
2.or表示并
3.and的优先级比or高
(firstname='thomas' or firstname='william') and lastname='carter' 会得到 lastname 必须为 carter ,firstname 为 thomas 或者 william的人 thomas carter william carterfirstname='thomas' or firstname='william' and lastname='carter' 可以得到 william carter 或者 firstname 为ithomas lastname 不一定是 carter的人 比如: thomas carter william carter thomas king
就是 or 和and 的先后顺序的问题, and 的优先级比 or的高 ,a or b and c 先计算 b and c 的结果 再去计算 a 的。
and优先级大于or。
加括号则优先执行or,后执行and;不加括号,会先执行and,再执行or,所以查询结果不同。举例:
数据库存在数据:
thomas carter
william carter
thomas king
执行:
select * from persons where (firstname='thomas' or firstname='william')and lastname='carter'
结果为:
thomas carter
william carter
执行:
select * from persons where firstname='thomas' or firstname='william'and lastname='carter'
结果为:
thomas carter
william carter
thomas king
推荐教程:《oracle视频教程》
以上就是oracle中and和or的区别是什么的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product