2016-07-28 10 views
1

サブクエリを使用しないで、配列のすべての要素が数値のサブセットに等しいかどうかを調べたいと思います。だから1 = ALL(ARRAY[1,1,1])の代わりにALL(ARRAY[1,1,1]) IN (1, 5)のようなことをしたいと思います。これはselect文を使わないと可能ですか?Postgresql ALL with IN

答えて

0

@>演算子を使用します。

-- does the column contain at-least one of 
select * from test_arrays where values && array[6, 9]; 
select * from test_arrays where values && '{6, 9}'::int[]; 

は、私は数ヶ月前にこのことについて書くことが起こった:あなたは、配列のいずれか1つの値が&&演算子を使用する他の配列である場合検索したい場合は

-- does the column contain all of 
select * from test_arrays where values @> array[6, 9]; 
select * from test_arrays where values @> '{6, 9}'::int[]; 

http://www.philliphaydon.com/2016/05/07/postgresql-and-its-array-datatype/