- Categories:
Semi-structured and Structured Data Functions (Array/Object)
ARRAY_CONTAINS¶
Returns TRUE if the specified value is found in the specified ARRAY.
Syntax¶
ARRAY_CONTAINS( <value_expr> , <array> )
Arguments¶
value_expr
Value to find in
array
.If
array
is a semi-structured ARRAY,value_expr
must evaluate to a VARIANT.If
array
is a structured ARRAY,value_expr
must evaluate to a type that is comparable to the type of the ARRAY.
array
The ARRAY to search.
Returns¶
The function returns TRUE if value
is present in array
.
Examples¶
The following queries demonstrate basic usage of the ARRAY_CONTAINS
function:
SELECT ARRAY_CONTAINS('hello'::variant, array_construct('hello', 'hi')); +------------------------------------------------------------------+ | ARRAY_CONTAINS('HELLO'::VARIANT, ARRAY_CONSTRUCT('HELLO', 'HI')) | |------------------------------------------------------------------| | True | +------------------------------------------------------------------+SELECT ARRAY_CONTAINS('hello'::variant, array_construct('hola', 'bonjour')); +----------------------------------------------------------------------+ | ARRAY_CONTAINS('HELLO'::VARIANT, ARRAY_CONSTRUCT('HOLA', 'BONJOUR')) | |----------------------------------------------------------------------| | False | +----------------------------------------------------------------------+