To update the primary key column starting with "1" in a table named "tablename," use the following query:
SET @INDEX = 0;
UPDATE `tablename` SET `primary_key`= (@INDEX:=@INDEX+1);
Additionally, adjust the AUTO_INCREMENT value for the table by executing the following query:
ALTER TABLE `tablename` AUTO_INCREMENT = 100;
Setting AUTO_INCREMENT to 100 ensures that the next row generated will have an "primary_key" following the specified sequence. Make sure to replace "tablename" and "primary_key" with the actual data in your queries and set AUTO_INCREMENT to the desired starting value.
Most Commented