I need to update the table fields and substitute the value of the variable to be incremented, namely

DECLARE counter int2 = 0; BEGIN UPDATE table SET field1 = counter++ (не работает, взял для наглядности) WHERE field2 IN (1,2,3,45,56,76) 

Tell me how it is done in PostgreSQL.

thank

PS I know about field1 = field1 + 1, the task is the above

  • update with join with a subquery and calculating the sequence number using row_number (). about how here.stackoverflow.com/a/545766/194569 in the request for renumbering - Mike
  • Thank you so much, I will study - Ilya Bazhinov

0