Available in versions: Dev (3.21)
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
ARRAY_CONTAINS
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The ARRAY_CONTAINS
function allows for checking if a value is contained in an array:
SELECT array_contains(ARRAY[1, 2, 2, 3], 2)
create.select(arrayContains(array(1, 2, 2, 3), val(2))).fetch();
The result would look like this:
+-----------------+ | array_contains | +-----------------+ | true | +-----------------+
Dialect support
This example using jOOQ:
arrayContains(array(1, 2, 2, 3), val(2))
Translates to the following dialect specific expressions:
Aurora Postgres, CockroachDB, Postgres, YugabyteDB
ARRAY[1, 2, 2, 3] @> ARRAY[2]
BigQuery
EXISTS ( SELECT 1 FROM ( SELECT null e FROM UNNEST([STRUCT(1 AS dual)]) AS dual WHERE FALSE UNION ALL SELECT * FROM UNNEST(ARRAY[1, 2, 2, 3]) t ) t WHERE e = 2 )
ClickHouse
has( ARRAY(1, 2, 2, 3), 2 )
Databricks
array_contains( ARRAY(1, 2, 2, 3), 2 )
DuckDB
list_contains( ARRAY[1, 2, 2, 3], 2 )
H2
array_contains( ARRAY[1, 2, 2, 3], 2 )
HSQLDB
(position_array(2 IN ARRAY[1, 2, 2, 3]) > 0)
Trino
contains( ARRAY[1, 2, 2, 3], 2 )
ASE, Access, Aurora MySQL, DB2, Derby, Exasol, Firebird, Hana, Informix, MariaDB, MemSQL, MySQL, Oracle, Redshift, SQLDataWarehouse, SQLServer, SQLite, Snowflake, Sybase, Teradata, Vertica
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!