Let’s say I have a table like this:
name |order_id
=======================
first_record | 0
second_record | 0
third_record | 0
[...]
I want to update just order_id with an incremented value (not sure how to put this correctly in english – feel free to edit with a better description). See expected output below:
name |order_id
=======================
first_record | 1
second_record | 2
third_record | 3
[...] | n
I know how to do this either by using a script in some programming language or a sql procedure, both solution involve looping the whole table.
You can update table:
Or just get order_id as returned row number while selecting: