IN

All functions > COMPARISON > IN

Returns TRUE if a value exists in a list of values.

Syntax

expr IN (value, value, ...)

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
  • 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 OR across the list

Related Functions

Examples

Numeric values

FeatureQL
SELECT
    f1 := 5 IN (1, 2, 3, 4, 5), -- Number in list
    f2 := 6 IN (1, 2, 3, 4, 5), -- Number not in list
    f3 := NULL::BIGINT IN (1, 2, 3) -- NULL value
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEAN
truefalseNULL

String values

FeatureQL
SELECT
    f1 := 'apple' IN ('apple', 'banana', 'cherry'), -- String in list
    f2 := 'grape' IN ('apple', 'banana', 'cherry'), -- String not in list
    f3 := NULL::VARCHAR IN ('a', 'b', 'c') -- NULL string
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEAN
truefalseNULL

Other types

FeatureQL
SELECT
    f1 := TRUE IN (TRUE, FALSE), -- Boolean in list
    f2 := DATE '2024-01-01' IN (DATE '2024-01-01', DATE '2024-12-31') -- Date in list
;
Result
f1 BOOLEANf2 BOOLEAN
truetrue

NULL edge cases

FeatureQL
SELECT
    f1 := 2 IN (1, NULL::BIGINT, 3) -- NULL in list: unknown without a definite match
;
Result
f1 BOOLEAN
NULL

Last update at: 2026/05/26 17:22:09