Click to See Complete Forum and Search --> : Simple Mysql question...


r_sole
06-15-2007, 01:00 AM
How can I stop the auto increment just keep going up? How can I make it so it counts the amount of rows instead?

For example, if I had 3 rows (auto increments up to 3) and then decided to delete number 3, I want the auto increment to be 3 next time (because now theres only 2 rows left and 3 should be the next in the sequence) but instead 4 will be the next increment.

Chris J
06-15-2007, 01:10 AM
Just run the following sql query:

ALTER TABLE tablename AUTO_INCREMENT = 3

r_sole
06-15-2007, 03:58 AM
hmm alright. Thanks

Michaelttkk
06-16-2007, 09:16 AM
another possible solution I have been using is, you delete the autoincremented no/number and recreated it.

example, no firstname lastname (the table structure)
delete the no

then, recreated the no again(autoincremented etc.) before the firstname