IN
All functions > COMPARISON > IN
Returns TRUE if a value exists in a list of values.
Syntax
expr IN (value, value, ...)
Function form
Returns: Membership result; NULL in edge cases involving NULL inputs or list elements
IN_LIST(expr: T, list_of_exprs: ARRAY<T>) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | T | Yes | Value to test for membership |
list_of_exprs | ARRAY<T> | Yes | Array of candidate values dynamic array |
Notes
- Value and list elements must be of compatible types
- Returns TRUE if any element in the list matches the value
- Returns FALSE if the value is not found in the list
- Equivalent to chaining three-valued
=with OR across the list (NOT INis NOT of that OR) - On FLOAT/DOUBLE, write
IN.N(for exampleIN.3). Omitting it uses 15 digits and warns - NULL value, NULL list element without a definite match, or nested-NULL ROW/ARRAY membership → NULL
- ROW / ARRAY /
ARRAY<ROW>membership uses the same poisoned-pair=rules
Examples
Numeric values
FeatureQL
RETURN
-- Number in list
f1 := 5 IN (1, 2, 3, 4, 5),
-- Number not in list
f2 := 6 IN (1, 2, 3, 4, 5),
-- NULL value
f3 := NULL::BIGINT IN (1, 2, 3)
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN |
|---|---|---|
| true | false | NULL |
String values
FeatureQL
RETURN
-- String in list
f1 := 'apple' IN ('apple', 'banana', 'cherry'),
-- String not in list
f2 := 'grape' IN ('apple', 'banana', 'cherry'),
-- NULL string
f3 := NULL::VARCHAR IN ('a', 'b', 'c')
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN |
|---|---|---|
| true | false | NULL |
Other types
FeatureQL
RETURN
-- Boolean in list
f1 := TRUE IN (TRUE, FALSE),
-- Date in list
f2 := DATE '2024-01-01' IN (DATE '2024-01-01', DATE '2024-12-31')
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | true |
NULL edge cases
FeatureQL
RETURN
-- NULL in list: unknown without a definite match
f1 := 2 IN (1, NULL::BIGINT, 3),
-- ROW membership uses three-valued `=`
f2 := ROW(1::BIGINT, NULL::BIGINT) IN (ROW(1::BIGINT, NULL::BIGINT))
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| NULL | NULL |
IN_LIST — registry encoding
FeatureQL
RETURN
-- Equivalent to `IN` with a literal list
f1 := IN_LIST(7, ARRAY(1, 3, 7, 9)),
-- Value not in candidate array
f2 := IN_LIST(2, ARRAY(1, 3, 7, 9))
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
IN_LIST — NULL edge cases
FeatureQL
RETURN
-- NULL probe value
f1 := IN_LIST(NULL::BIGINT, ARRAY(1, 2, 3)),
-- NULL in candidates: unknown without a definite match
f2 := IN_LIST(2, ARRAY(1, NULL::BIGINT, 3))
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| NULL | NULL |