NOT IN
All functions > COMPARISON > NOT IN
Returns TRUE if a value does NOT exist in a list of values.
Syntax
expr NOT IN (value, value, ...)
Function form
Returns: Membership result; NULL in edge cases involving NULL inputs or list elements
NOT_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 the value does not match any element in the list
- Returns FALSE if the value is found in the list
- NULL handling: if value is NULL, returns NULL; if any list element is NULL and value doesn't match other elements, returns NULL
- Equivalent to chaining
!=with AND across the list - Opposite of IN
- On FLOAT/DOUBLE,
NOT IN.Ncompares withEQUALSat N decimal places. Omitting it uses 15 digits and warns
Examples
Numeric values
FeatureQL
RETURN
-- Number not in list
f1 := 6 NOT IN (1, 2, 3, 4, 5),
-- Number in list
f2 := 5 NOT IN (1, 2, 3, 4, 5),
-- NULL value
f3 := NULL::BIGINT NOT IN (1, 2, 3)
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN |
|---|---|---|
| true | false | NULL |
String values
FeatureQL
RETURN
-- String not in list
f1 := 'grape' NOT IN ('apple', 'banana', 'cherry'),
-- String in list
f2 := 'apple' NOT IN ('apple', 'banana', 'cherry'),
-- NULL string
f3 := NULL::VARCHAR NOT IN ('a', 'b', 'c')
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN |
|---|---|---|
| true | false | NULL |
Other types
FeatureQL
RETURN
-- Boolean not in list
f1 := FALSE NOT IN (TRUE),
-- Date not in list
f2 := DATE '2024-06-15' NOT IN (DATE '2024-01-01', DATE '2024-12-31')
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | true |
NOT_IN_LIST — registry encoding
FeatureQL
RETURN
-- Equivalent to `NOT IN` with a literal list
f1 := NOT_IN_LIST(99, ARRAY(1, 2, 3)),
-- Value present in candidate array
f2 := NOT_IN_LIST(2, ARRAY(1, 2, 3))
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
NOT_IN_LIST — NULL edge cases
FeatureQL
RETURN
-- NULL probe value
f1 := NOT_IN_LIST(NULL::BIGINT, ARRAY(1, 2, 3))
;Result
| f1 BOOLEAN |
|---|
| NULL |