SETEQ Operator

Description

The SETEQ operator returns TRUE if the first operand is the same as the second one. It can perform comparison operator for all collection data type.

Syntax

collection_operand SETEQ collection_operand

Example

--creating a table with SET type address column and LIST type zip_code column

 

CREATE TABLE contain_tbl (id int primary key, name char(10), address SET varchar(20), zip_code LIST int);

INSERT INTO contain_tbl VALUES(1, 'Kim', {'country', 'state'},{1, 2, 3});

INSERT INTO contain_tbl VALUES(2, 'Moy', {'country', 'state'},{3, 2, 1});

INSERT INTO contain_tbl VALUES(3, 'Jones', {'country', 'state', 'city'},{1,2,3,4});

INSERT INTO contain_tbl VALUES(4, 'Smith', {'country', 'state', 'city', 'street'},{1,2,3,4});

INSERT INTO contain_tbl VALUES(5, 'Kim', {'country', 'state', 'city', 'street'},{1,2,3,4});

INSERT INTO contain_tbl VALUES(6, 'Smith', {'country', 'state', 'city', 'street'},{1,2,3,5});

INSERT INTO contain_tbl VALUES(7, 'Brown', {'country', 'state', 'city', 'street'},{});

 

--selecting rows when two collection_operands are same in the WEHRE clause

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

           id  name                  address               zip_code

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

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

 

1 row selected.

 

--selecting rows when two collection_operands are same in the WEHRE clause

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

 

           id  name                  address               zip_code

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

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

 

1 rows selected.