SETCONTAINSANY() function
SETCONTAINSANY()
returns True when one or more specified values are found within an IDSET
or STRINGSET
column.
Syntax
SETCONTAINSANY(
{idset-column, [int-value,...]} |
{stringset-column, ['string-value',...]}
)
Arguments
Argument | Description | Data type |
---|---|---|
idset-column | Source column of idset data type | |
int-value | One or more integer values to search for within the idset-column | |
stringset-column | Source column of idset data type | |
'stringset-value' | One or more string values contained in single quotes to search for within the idset-column | |
[ ] | Required square brackets |
Returns
Column contains | Data type | Result |
---|---|---|
One or more values | Boolean | True |
Examples
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] |
+-----+------------------+
Testing set membership in the select list
This query returns TRUE
SELECT SETCONTAINSANY
(segment, ['BLUE', 'RED'])
AS HasBlueOrRed
FROM segments;
Testing set membership as a where clause filter
This query returns TRUE
.
SELECT _id, segment
FROM segments
WHERE SETCONTAINSANY
(segment, ['BLUE', 'RED']);