PSQL Batch Update Statement
I am trying to update a bunch of rows in a psql database, and would like to do it in one generated sql statement if possible. I am able to generate batch insert statements which look similar to this:
INSERT INTO my_table (col1, col2, col3) VALUES (v11, v12, v13), (v21, v22, v23), ...
However I am not sure how to do this with an update statement instead. I could do one SQL statement for each row I want to update but this seems unnecessary and slower than having just one statement
P.S. all rows have an id column so I can reference them through that
I was able to find the answer at the above link. looks similar to
UPDATE my_table SET x = case when y = '1' then '1.1' when y = '2' then '1.2' end WHERE y='1' OR y='2';