PDA

View Full Version : MySQL question.


tribby
05-05-2001, 05:39 PM
Hi,

I have a MySQL table with a field called 'ID' which is set to auto-increment. Let's say that the current highest id is 150. The next ID that will be added is 151. But if I then delete the entry for 151 with 'DELETE FROM tablename WHERE ID=151', and then another entry is added, the ID is 152, when it shpuld be 151. Does anyone know how I can fix this?

Thanks!

RandMan
05-05-2001, 08:25 PM
The autoincrement function seems to work this way. MySQL maintains its own running index. I would be interested in knowing the answer to this also.

petesmc
05-05-2001, 08:32 PM
Hi,

This is how auto-increment works in MySQL. The only solution is to empty the table and re-enter all the data again which is very impractical.

-Peter

jetsetter
05-05-2001, 08:52 PM
Think of it like a check you write that you later rip up.

That check number is gone forever...

Joe

tribby
05-05-2001, 09:02 PM
Got it. Thanks for clearing that up, everyone. I'm just recently migrating for the Perl/flatfile method to the PHP/MySQL combination that seems to be so popular these days... ;)