thiebo
thiebo

Reputation: 1435

update several columns of a table at once

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?

Upvotes: 0

Views: 30

Answers (1)

user330315
user330315

Reputation:

Use an IN operator:

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

Upvotes: 1

Related Questions