SUBSETEQ 연산자

설명

SUBSETEQ 연산자는 두 번째 피연산자가 첫 번째 피연산자의 모든 원소를 포함하거나 서로 동일한 경우, 즉 첫 번째 피연산자가 두 번째 피연산자의 부분집합인 경우 TRUE(1)을 반환한다. 단, 피연산자가 모두 LIST 타입인 경우에는 SUBSETEQ 연산을 지원하지 않는다.

구문

collection_operand SUBSETEQ collection_operand

예제

--selecting rows when the first operand is a subset of the second operand

SELECT id, name, address, zip_code FROM contain_tbl WHERE address SUBSETEQ {'country','state','city'};

           id  name                  address               zip_code

===============================================================================

            1  'Kim       '          {'country', 'state'}  {1, 2, 3}

            2  'Moy       '          {'country', 'state'}  {3, 2, 1}

            3  'Jones     '          {'city', 'country', 'state'}  {1, 2, 3, 4}

 

--SUBSETEQ operator cannot be used for comparison between LIST and LIST type values

SELECT id, name, address, zip_code FROM contain_tbl WHERE zip_code SUBSETEQ {1,2,3};

 

ERROR: ' subseteq ' operator is not defined on types sequence and sequence.

 

--Comparing operands with a SUBSETEQ operator after casting LIST type as SET type

SELECT id, name, address, zip_code FROM contain_tbl WHERE zip_code SUBSETEQ (CAST ({1,2,3} AS SET));

           id  name                  address               zip_code

===============================================================================

            1  'Kim       '          {'country', 'state'}  {1, 2, 3}

            7  'Brown     '          {'city', 'country', 'state', 'street'}  {}