Jump to content

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


priya171

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?

Archived

This topic is now archived and is closed to further replies.

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