store current auto increment value
Moderator: General Moderators
-
greedyisg00d
- Forum Commoner
- Posts: 42
- Joined: Thu Feb 12, 2009 2:48 am
store current auto increment value
I have a Student table and StudNo field which is set as primary key and auto increment is enabled. My problem is when I delete a specific row I noticed that the auto increment value remains the same. So is there a way to get the current auto increment value and store it to a variable? Sample code is much appreciated. Thanks
Re: store current auto increment value
in mysql, I dont think an autoincrement field will decrement if you delete a record! It just keeps on incrementing. You will have to re-write the table to somewhere else if you need the autoincrement numbers to be sequential after you delete a record.
There is a mysql command to get the contents of the autoincrement field I believe. Although it might be a php mysql_ function I cannot remember, but I know I have seen it available.
There is a mysql command to get the contents of the autoincrement field I believe. Although it might be a php mysql_ function I cannot remember, but I know I have seen it available.
Re: store current auto increment value
Whatever you want to do, don't. Not this way. An auto-increment field is the square peg solution to the round hole problem you have - find something else. Want advice: describe what you're trying to do.
(PS: ocpaul20 is probably thinking of mysql_insert_id but that does something slightly different.)
(PS: ocpaul20 is probably thinking of mysql_insert_id but that does something slightly different.)