MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 30th, 2000, 02:49 AM
baldwnad baldwnad is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 30 baldwnad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to baldwnad
Here is the senerio. I have 1 table (members) and an primary ID that is autoincrmenting. I rely on this ID to be in order i.e 1,2,3,4,5..... If I go and say do this

Delete from members where (ID = 3);

My order now reads... 1,2,4,5....
Is there anyway to execute a specific MySQL command to make those numbers sync up after deleting the spcific row? Thanks!!!!

Reply With Quote
  #2  
Old June 1st, 2000, 07:51 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
If only one row is deleted and you know which row it is, then

> update table
> set id=id-1
> where id>3;

should work

Reply With Quote
  #3  
Old June 9th, 2000, 07:23 AM
Adrian2 Adrian2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: London, England
Posts: 251 Adrian2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
The only reason I can think that you would want to do this is if you need to keep track of the order in which the records were entered.

If so, you'd be better off creating a field with the type DATETIME and assigning NOW() into it when the record is created.

Then you can sort by this field and even assign order numbers on the fly in your output without worrying about your autoincremented key being complete.

Reply With Quote
  #4  
Old June 9th, 2000, 08:20 AM
baldwnad baldwnad is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 30 baldwnad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to baldwnad
Just so everyone knows I finally figured out what I was doing. I ended up using a limit statment to grab the next 10 records. I changed my code around to only use the autoincrementing ID for updating, not displaying. Thanks to everyone who gave me ideas!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Auto incrementing ID


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT