mhiro216
mhiro216

Reputation: 91

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.

Upvotes: 0

Views: 115

Answers (1)

Popeye
Popeye

Reputation: 35910

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

array_replace(your_column, 10, 999) 

Upvotes: 2

Related Questions