PostgreSQL – ARRAY_REMOVE Function
The array_remove
function in PostgreSQL is used to remove all occurrences of a specified value from an array. It takes two arguments: the array from which you want to remove elements and the value you want to remove.
Below is the syntax of the array_remove
function:
array_remove(array, value_to_remove)
Where:
array
is the array from which you want to remove elements.
value_to_remove
is the value you want to remove from the array.
Here’s an example of using the array_remove
function:
SELECT array_remove('{10, 20, 30, 40, 20}', 20) AS result_array;
The output would be:
result_array
--------------
{10,30,40}
(1 row)
In this example, the array_remove
function removed all occurrences of the value 20
from the input array.