Jump to content


Photo

Auto Increment - Deletion


  • Please log in to reply
3 replies to this topic

#1 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 27 September 2006 - 10:34 PM

I have my ID field set up as auto increment

Now, lets say I have the following in a database in the ID field

1
2
3
4

If I delete record 4, that means I will be left with

1
2
3

However, and here is my problem. When a new record is added, it auto increments the ID field to 5. Obviously their is some kind of counter which still holds 4 as the last number.

Is their anyway around this without querying the database?
I would love to change the world, but they won't give me the source code

SEO Agency

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 27 September 2006 - 10:36 PM

Any way around what?  What are you using this field for that it matters?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 27 September 2006 - 11:00 PM

Song ID's.

In other words, I want it to auto increment from the last ID in the table
I would love to change the world, but they won't give me the source code

SEO Agency

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 September 2006 - 11:25 PM

Treat auto-incrementing fields as if they belong to MySQL (which they do) and you can't mess with them, instead of something that's yours.  You'll be glad you did when you want to use ids from different tables to do some cross-referencing.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users