Generating new id’s in ascending order in MySQL

Simple example of generating new id’s in ascending order in MySQL.

SET @count = 0;
UPDATE `users` SET `users`.`id` = @count:= @count + 1;

Leave a Reply

Your email address will not be published.