Available in versions: Dev (3.20) | Latest (3.19) | 3.18

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_REMOVE

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The ARRAY_REMOVE function allows for removing all occurrences of an element from an array:

SELECT array_remove(ARRAY[1, 2, 2, 3], 2)
create.select(arrayRemove(array(1, 2, 2, 3), 2)).fetch();

The result would look like this:

+--------------+
| array_remove |
+--------------+
| [1, 3]       |
+--------------+

Dialect support

This example using jOOQ:

arrayRemove(array(1, 2, 2, 3), 2)

Translates to the following dialect specific expressions:

Aurora Postgres, CockroachDB, Postgres, Trino, YugabyteDB

array_remove(
  ARRAY[1, 2, 2, 3],
  2
)

DuckDB

array_filter(
  ARRAY[1, 2, 2, 3],
  e -> e <> 2
)

H2, HSQLDB

(
  SELECT coalesce(
    array_agg(e),
    CAST(ARRAY[] AS int array)
  )
  FROM UNNEST(ARRAY[1, 2, 2, 3]) t (e)
  WHERE e <> 2
)

ASE, Access, Aurora MySQL, BigQuery, ClickHouse, DB2, Derby, Exasol, Firebird, Hana, Informix, MariaDB, MemSQL, MySQL, Oracle, Redshift, SQLDataWarehouse, SQLServer, SQLite, Snowflake, Sybase, Teradata, Vertica

/* UNSUPPORTED */

(These are currently generated with jOOQ 3.20, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo