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_GET
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The ARRAY_GET
function allows for accessing array elements by 1-based ordinal.
SELECT (ARRAY[1, 2])[1]
create.select(arrayGet(array(1, 2), 1)).fetch();
The result would look like this:
+-----------+ | array_get | +-----------+ | 1 | +-----------+
Dialect support
This example using jOOQ:
arrayGet(array(1, 2), 1)
Translates to the following dialect specific expressions:
Aurora Postgres, CockroachDB, DuckDB, H2, Postgres, YugabyteDB
(ARRAY[1, 2])[1]
BigQuery
(ARRAY[1, 2])[safe_ordinal(1)]
ClickHouse
(ARRAY(1, 2))[1]
HSQLDB
CASE WHEN cardinality(ARRAY[1, 2]) >= 1 THEN (ARRAY[1, 2])[1] END
Trino
element_at( ARRAY[1, 2], 1 )
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.20. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!