Oracle: #39;= ANY()#39; vs. #39;IN ()#39;(甲骨文:= ANY() vs. IN())
问题描述
我刚刚在 ORACLE SQL 中偶然发现了一些我很好奇的东西(不确定它是否在其他人中).我在这里作为维基询问,因为很难尝试在谷歌中搜索符号......
I just stumbled upon something in ORACLE SQL (not sure if it's in others), that I am curious about. I am asking here as a wiki, since it's hard to try to search symbols in google...
我刚刚发现,当根据一组值检查一个值时,您可以这样做
I just found that when checking a value against a set of values you can do
WHERE x = ANY (a, b, c)
相对于通常的
WHERE x IN (a, b, c)
所以我很好奇,这两种语法的原因是什么?一种是标准,另一种是一些古怪的 Oracle 语法吗?还是两者都是标准的?出于性能原因,是否有一种偏好,或者?
So I'm curious, what is the reasoning for these two syntaxes? Is one standard and one some oddball Oracle syntax? Or are they both standard? And is there a preference of one over the other for performance reasons, or ?
只是好奇有人能告诉我关于= ANY"的语法.加油!
Just curious what anyone can tell me about that '= ANY' syntax. CheerZ!
推荐答案
ANY
(或其同义词SOME
)是EXISTS
具有简单的相关性:
ANY
(or its synonym SOME
) is a syntax sugar for EXISTS
with a simple correlation:
SELECT *
FROM mytable
WHERE x <= ANY
(
SELECT y
FROM othertable
)
等同于:
SELECT *
FROM mytable m
WHERE EXISTS
(
SELECT NULL
FROM othertable o
WHERE m.x <= o.y
)
对于不可为空的字段上的相等条件,它变得类似于IN
.
With the equality condition on a not-nullable field, it becomes similar to IN
.
所有主流数据库,包括SQL Server
、MySQL
和PostgreSQL
,都支持该关键字.
All major databases, including SQL Server
, MySQL
and PostgreSQL
, support this keyword.
这篇关于甲骨文:'= ANY()' vs. 'IN()'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:甲骨文:'= ANY()' vs. 'IN()'


基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01