2016-07-28 2 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/