469,926 Members | 1,557 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

mysql insert records in the middle of database table

Question.
-------------------

I have a table with field serial number(slno double).

I have data like this:
slno
-----
1
2
3
4

Now I want to insert a record between 3 and 4, so that the new record
should have the number 5 .
How to implement this? Same case with deleting a record also.
Jul 19 '05 #1
3 4893
On 11 Aug 2003 22:58:32 -0700, in mailing.database.mysql
br*****@divinetaccess.com (brijesh) wrote:
| Question.
| -------------------
|
| I have a table with field serial number(slno double).
|
| I have data like this:
| slno
| -----
| 1
| 2
| 3
| 4
|
| Now I want to insert a record between 3 and 4, so that the new record
| should have the number 5 .
| How to implement this? Same case with deleting a record also.


There's no need to do this. Use a query to sort your data for you i.e.
Select slno from myTable Order by slno;

---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 19 '05 #2
On 11 Aug 2003 22:58:32 -0700, in mailing.database.mysql
br*****@divinetaccess.com (brijesh) wrote:
| Question.
| -------------------
|
| I have a table with field serial number(slno double).
|
| I have data like this:
| slno
| -----
| 1
| 2
| 3
| 4
|
| Now I want to insert a record between 3 and 4, so that the new record
| should have the number 5 .
| How to implement this? Same case with deleting a record also.


There's no need to do this. Use a query to sort your data for you i.e.
Select slno from myTable Order by slno;

---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 19 '05 #3
On 11 Aug 2003 22:58:32 -0700, in mailing.database.mysql
br*****@divinetaccess.com (brijesh) wrote:
| Question.
| -------------------
|
| I have a table with field serial number(slno double).
|
| I have data like this:
| slno
| -----
| 1
| 2
| 3
| 4
|
| Now I want to insert a record between 3 and 4, so that the new record
| should have the number 5 .
| How to implement this? Same case with deleting a record also.


There's no need to do this. Use a query to sort your data for you i.e.
Select slno from myTable Order by slno;

---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Google Mike | last post: by
reply views Thread by Lenz Grimmer | last post: by
reply views Thread by Mike Chirico | last post: by
5 posts views Thread by himilecyclist | last post: by
Atli
6 posts views Thread by Atli | last post: by
9 posts views Thread by KDawg44 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.