Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - The Mysql table is unclear, so the id is reordered from 1. For example, there are 5000 data in the existing table, and the id is 5000 to 10000. How did it become 1-5000?
The Mysql table is unclear, so the id is reordered from 1. For example, there are 5000 data in the existing table, and the id is 5000 to 10000. How did it become 1-5000?
If the primary key ID of the original table is continuous data 5000 to 10000.

You can then use the update table name set id = id-4999;;

If the primary key ID of your original table is not continuous, the above method will not work.

Execute the first sentence first: SELECT @rownum := 0.

Then execute the following sentences.

Update the table name to t set t.id = (select (@ rownum: = @ rownum+1)).