ARRAY_REMOVE()
All functions > ARRAY > ARRAY_REMOVE()
Returns an array with all occurrences of the specified element removed.
Signatures
Returns: A new array with all occurrences of the specified element removed
ARRAY_REMOVE(array: ARRAY<T>, element: T) → ARRAY<T> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | The input array from which to remove elements |
element | T | Yes | The element to remove from the array |
Notes
- Removes ALL occurrences of the specified element
- Result keeps array position
- Returns empty array if all elements are removed
- NULL elements stay unless the searched value is NULL
- Searching for NULL is a no-op (SQL three-valued membership: NULL does not match NULL)
- Supports
ARRAY<ROW>andARRAY<ARRAY<T>>: element equality usesIS DISTINCT FROM(exact structural match) - On DOUBLE, an optional third argument is comparison digits (
EQUALSat N decimal places), not a start index. Omitting it uses 15 digits and warns
Availability
| Status | Backends |
|---|---|
| Not available | mysql |
See also
Examples
FeatureQL
RETURN
-- Remove all occurrences of 2
f1 := ARRAY_REMOVE(ARRAY(1, 2, 2, 3, 2), 2),
-- Remove all occurrences of 'A'
f2 := ARRAY_REMOVE(ARRAY('A', 'B', 'A', 'C'), 'A'),
-- Element not in array
f3 := ARRAY_REMOVE(ARRAY(1, 2, 3), 4),
-- Remove all elements
f4 := ARRAY_REMOVE(ARRAY(5, 5, 5), 5),
-- Remove specific string
f5 := ARRAY_REMOVE(ARRAY('apple', 'banana'), 'apple'),
-- Empty array
f6 := ARRAY_REMOVE(ARRAY()::ARRAY<BIGINT>, 1)
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY | f4 ARRAY | f5 ARRAY | f6 ARRAY |
|---|---|---|---|---|---|
| [1, 3] | [B, C] | [1, 2, 3] | [] | [banana] | [] |
On this page