PostgreSQL: Updating a list with a single query

Use the following query to update multiple rows using a single query for performance improvements.


update test as t set
column_a = c.column_a
from (values
('123', 1),
('345', 2)
) as c(column_b, column_a)
where c.column_b = t.column_b;

Leave a Reply

Your email address will not be published. Required fields are marked *