在 Postgres 中,ANY
和 SOME
在谓词表达式的右侧使用时是同义词。例如,这些是相同的:
column = ANY (SELECT ...)
column = SOME (SELECT ...)
这是记录在这里:
http://www.postgresql.org/docs/9.1/static/functions-subquery.html#FUNCTIONS-SUBQUERY-ANY-SOME
我观察到
ANY
和 SOME
至少由这些 SQL DBMS 支持:我可以安全地假设所有这些方言(以及其他方言)都适用于
ANY
和 SOME
作为同义词还是任何/某些 DBMS 中的两个关键字之间存在细微差别?我在 SQL92 定义中发现了这一点:
<quantifier> ::= <all> | <some>
<all> ::= ALL
<some> ::= SOME | ANY
这并没有说明
ANY
的语义。和 SOME
.后来在文档中,只有 <some>
是引用的,不是这两个关键字。我怀疑 NULL
中可能存在细微差别处理,例如,至少在某些 DBMS 中。欢迎任何/一些指向明确声明是否可以假设的指针。
最佳答案
在您引用的几行之后,SQL92 标准还指定了 <some>
的语义。 ,即:
c) If the implied <comparison predicate> is true for at least
one row RT in T, then "R <comp op> <some> T" is true.
d) If T is empty or if the implied <comparison predicate> is
false for every row RT in T, then "R <comp op> <some> T" is
false.
e) If "R <comp op> <quantifier> T" is neither true nor false,
then it is unknown.
这些规则适用于
<some>
token ,独立于它是 SOME 还是 ANY 替代品,所以是的,根据标准,它们是同义词
关于sql - SQL ANY 和 SOME 关键字在所有 SQL 方言中都是同义词吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8771596/