Reputation: 127
Hello everyone I just started on working with postgreSQL and i was wondering if there is a simple solution to delete a single value from an array. In the screenshot im trying to delete a single name from my array.
my PostgreSQL version: "PostgreSQL 12.4, compiled by Visual C++ build 1914, 64-bit"
Upvotes: 1
Views: 912
Reputation:
DELETE
removes an entire row from your table.
You want to change the content of one column of an existing row in the table - for that you need to use UPDATE
.
To remove a value from an array you the array_remove()
function:
update test
set name = array_remove(name, 'Jan')
where 'Jan' = any(name)
The where
clause makes sure that only rows are updated that actually contain the value Jan
in the array.
Upvotes: 2