0

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.

1 Answer 1

2

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

array_replace(your_column, 10, 999) 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! Since I want to update table, query as follows seems to do update table set column = array_replace(column, 10, 999);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.