Skip to main content Link Menu Expand (external link) Document Search Copy Copied

SETCONTAINS() function

SETCONTAINS() returns True when a specified value is found within an IDSET or STRINGSET column..


  {idset-column, integer-value} |
  {stringset-column, 'string-value'}


Argument Description Required
idset-column Column of idset data type to search within Yes
integer-value Single integer value to search for within idset-column Yes
stringset-column Column of stringset data type to search within Yes
string-value Single string value contained in single quotes to search for within stringset-column Yes


Column contains Data type Result
Specified value Boolean True


Testing set membership in the select list

Segments table

create table segments
    (_id id, segment stringset);
insert into segments(_id, segment)
    values (1, ['RED', 'BLUE', 'GREEN']);

| _id | segment          |
|   1 | [RED BLUE GREEN] |

This query returns true.

select setcontains(segment, 'BLUE') as HasBlue  
    from segments;  

Testing set membership as a where clause filter

This query returns true.

select _id, segment from segments where setcontains(segment, 'BLUE');