Resequencing problem with autoincrement

admin

Administrator
Staff member
Hi all,

Im using mysql 3.23.something.

I have problem with autoincrement column in a table im using. I've found a few ways to get around it but they all plain suck and are very complicated (i can see myself coming back to the app in a few months and getting confused).

I have column called id in a table with id, name, description. id is autoincrement. Autoincrement starts at 0.

Process:
3 rows are inserted into table.
row is deleted from table.
Problem:
so now next row will have value 4 for id but will be the third row. i need to be able to get what autoincrement is set at without doing an insert. I can't do this if the highest autoincrement valued row has been deleted.

I've checked manual. Nature of app means i can't simply resequence column. Also appears that i can't use LAST_INSERT_ID() as this is only maintained on a per connection basis. And no id love to but i can't change databases to the one you love ;-).

Thanks heaps for your time,
Billy
 
Back
Top