Jump to content
MakeWebGames

Tables ID


Recommended Posts

I have a table in this case its my citys....the ID went from 9 to 100 so in order its like

1

2

3

4

5

6

7

8

9

100

101

102

103

Ok...now i have went back and changed everything to get the back in order...9, 10, 11, 12.....

But when I make a new on in the table it goes to exp....104

Is there a way tio make it pick up from where it left off? I hope you understand what i mean I suck at explaing, lol...I jjust want to get the table back in the right order.

Link to comment
Share on other sites

Re: Tables ID

Somewhere somehow your script must have made an addition of 90+ rows to the table, and then deleted it.

No need to delete the whole thing, just reset the AUTO_INCREMENT value.

I reckon you have set the ids of the cities already, so based upon your last id, modify the following:

ALTER TABLE `cities` AUTO_INCREMENT = 12

The number, change it to the last id in the table, plus one.

Now just run that in phpmyadmin and it should be fine.

Link to comment
Share on other sites

Re: Tables ID

Just to confirm Spudinski's post, you DO NOT NEED TO DELETE THE TABLE

Doing what Spudinski says will take your autoincrement back down where it should be.

There is a counter stored in the information schema that tells mysql what the next id should be in an auto increment field. It does NOT look at the last ID in the table, but at that counter stored in the information schema.

Link to comment
Share on other sites

Re: Tables ID

Sweet!!

Just a side note, you could set it to 1 and mysql would then check and see that hm, you've got id's going up to 15 and then correct that for you automatically.

So, when I need to do those things, I just set them to 1 and I'm done with it lol.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...