neur0maniak
asked on
Updating using current row number
I'm trying to update a field for a series of records to contain sequential numbers, like a fix to remove gaps in the numbers.
So that, if I can return the following table:
ID | Value
87 | 5
89 | 11
95 | 18
98 | 23
I want to be able to do a single UPDATE query, to make:
ID | Value
87 | 1
89 | 2
95 | 3
98 | 4
I would prefer an answer that is the same in both MSSQL and MySQL, but an answer for either one of them will earn the points
So that, if I can return the following table:
ID | Value
87 | 5
89 | 11
95 | 18
98 | 23
I want to be able to do a single UPDATE query, to make:
ID | Value
87 | 1
89 | 2
95 | 3
98 | 4
I would prefer an answer that is the same in both MSSQL and MySQL, but an answer for either one of them will earn the points
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.