So I have a MySQL database that I\'m using with a PHP site. Over the course of weeks of development, I\'m left with something like:
Table: users
id | name
Why do you need to change the order of the names in the database? You can just add an ORDER BY name
clause on your sql query to get the results in alphabetical order by name.
remove index on id
do something like this:
SET @rank:=0;
update users
set id=@rank:=@rank+1
order by id;
add index on id