2

最近、Quantified Comparison Predicates – Some of SQL's Rarest Speciesを読みました。

実際、SQL 標準では、IN 述語は、= ANY() 限定比較述語の単なる構文糖衣であると定義されています。

8.4 <in predicate>

Let RVC be the <row value predicand> and 
let IPV be the <in predicate value>.

The expression  RVC IN IPV
is equivalent to  RVC = ANY IPV

次のような他の回答に基づいて、十分に公平です:正確には「SOME / ANY」と「IN」</a>またはOracleとは何ですか: '= ANY()' vs. 'IN ()' 私はそれらを使用できると仮定しました交互に。

ここに私の例があります:

select 'match'
where 1 = any( string_to_array('1,2,3', ',')::int[])
-- match

select 'match'
where 1 IN ( string_to_array('1,2,3', ',')::int[])
-- ERROR:  operator does not exist: integer = integer[]
-- HINT:  No operator matches the given name and argument type(s).
-- You might need to add explicit type casts.

DBフィドル

問題は、最初のクエリが機能し、2 番目のクエリがエラーを返す理由です。

4

1 に答える 1