php - How to fix SQL indexes to remove spaces/jumps? -
i have table entries listed , edited , removed creates space. example: 1,2,4,5,6,8,10 have them in order example: 1,2,3,4,5,6,7
is there code qick , painless?
thank you.
if have foreign key constraints you'll need use on update cascade (something tend avoid plague).
is there reason ensure these numbers sequential or aesthetics?
there's no problem having keys 'missing' - database cares little.
if need then:
set @indx = 1; update `table` set `field` = (@indx:=@indx+1) order `field` asc;
have fun...
Comments
Post a Comment