Home > Enterprise >  update several columns of a table at once
update several columns of a table at once

Time:06-03

In postgresql, I want to update several rows of a table according to their id. This doesn't work:

    UPDATE table SET othertable_id = 5 WHERE id = 2, 45, 22, 75

What is the correct syntax for this?

CodePudding user response:

Use an IN operator:

update the_table
  set othertable_id = 5
where id in (2,45,22,75);
  • Related