I\'ve got a mysql table where each row has its own sequence number in a \"sequence\" column. However, when a row gets deleted, it leaves a gap. So...
1 2 3
Assuming that this is an ID field, you can do this when you insert:
INSERT INTO yourTable (ID) SELECT MIN(ID) FROM yourTable WHERE ID > 1
As others have mentioned I don't recommend doing this. It will hold a table lock while the next ID is evaluated.