Skip to main content

ARRAY_CONTAINS

Introduced or updated: v1.2.762

Returns true if the array contains the specified element.

Syntax​

ARRAY_CONTAINS(array, element)

Parameters​

ParameterDescription
arrayThe array to search within.
elementThe element to search for.

Return Type​

BOOLEAN

Notes​

This function works with both standard array types and variant array types.

Examples​

Example 1: Checking a Standard Array​

SELECT ARRAY_CONTAINS([1, 2, 3], 2);

Result:

true

Example 2: Checking a Variant Array​

SELECT ARRAY_CONTAINS(PARSE_JSON('["apple", "banana", "orange"]'), 'banana');

Result:

true

Example 3: Element Not Found​

SELECT ARRAY_CONTAINS([1, 2, 3], 4);

Result:

false
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today