So, lets say I have two ordered arrays with the same number of elements where each index of each array refers to the other one at the same index
values = [ 5, 7, 8, 9 ]
keys = ['a', 'b', 'c', 'd' ]
instead of doing multiple UPDATES inside a loop
for thing, index in values
UPDATE table SET column1 = thing WHERE column2 = keys[index]
is there a way to pull these arrays into Postgres and use them in a single UPDATE
query?
Something like:
UPDATE table SET column1 = values[?] WHERE column2 = keys[?]