The IS_MEMBER_OF
row function takes an atomic value and a set, and returns a Boolean indicating whether the atomic value occurs in the set.
IS_MEMBER_OF
function is:
IS_MEMBER_OF(<atomic-value>, <set>)
where:
{ }
indicates an empty set):
IS_MEMBER_OF(1, { }) = FALSE IS_MEMBER_OF(1, { 1, 2, 3 }) = TRUE IS_MEMBER_OF(1, { 2, 3, 4 }) = FALSE IS_MEMBER_OF(NULL, { }) = NULL IS_MEMBER_OF(NULL, { 1, 2, 3 }) = NULL IS_MEMBER_OF(1, { 'a', 'b', 'c' }) yields a checking error because the atomic value and the set elements are not of the same data type
The IS_MEMBER_OF
function is intended as a membership check function.
IS_MEMBER_OF examples
RETURN results AS SELECT WineID AS idRec, IS_MEMBER_OF(82, Score) AS memberAttrs FROM WineState WHERE WineID BETWEEN 22 AND 25 ORDER BY idRec
idRec memberAttrs -------------- | 22 | false | | 23 | true | | 24 | false | | 25 | true | --------------
The results show that the number 82 occurs in the Score set of Records 23 and 25, but not in Records 22 and 24.
IS_MEMBER_OF
function and the Score set (which has integer elements) as the second argument:
RETURN results AS SELECT WineID AS idRec, IS_MEMBER_OF(Ranking, Score) AS memberAttrs FROM WineState ORDER BY idRec
IS_MEMBER_OF
function in a WHERE
clause:
RETURN results AS SELECT WineID AS idRec, Price AS prices FROM WineState WHERE IS_MEMBER_OF(Ranking, Score) AND Price IS NOT NULL ORDER BY idRec
Using the IN expression
IN
expression as an alternative to the IS_MEMBER_OF
function for membership tests. To illustrate this, Example 3 can be re-written as:
RETURN results AS SELECT WineID AS idRec, Price AS prices FROM WineState WHERE Ranking IN Score AND Price IS NOT NULL ORDER BY idRec
For details on the IN
expression, see IN.