Skip to content
Advertisement

Query to replace partial values in an array of int in PostgreSQL

In PotgreSQL, how do I write a query to replace some values in an int4 array?

{1,2,10} -> {1,2,999}

{2,3,10} -> {2,3,999}

is what we are aiming for.

Advertisement

Answer

Seems like you want to replace 10 with 999, you can use array_replace

array_replace(your_column, 10, 999) 
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement