Mysql regenerate missing IDs from 1 to N -
I have a table with indexed column 1,2,3,4,8,9,13,55,66,67,68 .... 928746 < / P> How can I regenerate the sequence of Is it possible to do this with mysql query, without any code (PHP)? PS Anything depends on these IDs I can change them independently, do I just want to do any signals? replace [table] with your table name, [field] by your field name , And [primary_key] from the primary key column name to: id2 . After using this table to insert / delete records, there are some missing records. id2 starts this way
id2 , so the missing number [1,2,3,4,5,6. ..] is not? In addition, the id2 must be in line with the ts field, which is the Unix timestamp for record insertion.
SET @ rownum = 0; Update [Table] T, (SELECT @rownum: = @ rownum + 1 rownum, [table]. * From [table]) R set t. [Field] = R.Province where WHERE (T. [primary_key] = R. [primary_key])
Comments
Post a Comment