Jump to content

Insert record into mysql table having id auto increment between two existing row


Recommended Posts

i have table call test

id name dob mobile

1 xyz 1989-01-11 9878785687

2 pqr 2012-01-11 9977889988

3 abc 2010-09-19 7766554433

 

 

id is auto increment. now i have to add a record between 1 and 2 like udp 1977-09-08 9898009800

 

So my data table should be like this:

id name dob mobile

1 xyz 1989-01-11 9878785687

2 udp 1977-09-08 9898009800

3 pqr 2012-01-11 9977889988

4 abc 2010-09-19 7766554433

 

Help me....

 

ID values are unique identifiers given to records on insert and, once allocated, should never change.

 

Your application should work exactly the same if MySql allocated ids randomly instead of sequentially (easier and quicker). If they were allocated randomly, where would you put your new record?

 

What is there about that record that makes it imperative that it go between 1 and 2?

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.