Suppose you have a table as follow:
| Name | Id |
|---|---|
| John | |
| Peter | |
| George |
and you want to update the Id field with a sequential rank 1,2,3,4,... In MySQL this is a way to do so:
set @rank := 0; update T set Id = @rank:=@rank+1;
The table will look like this:
| Name | Id |
|---|---|
| John | 1 |
| Peter | 2 |
| George | 3 |