Nexy Posted June 4, 2008 Share Posted June 4, 2008 Hello, just a simple question. Lets say my primary key in Mysql was named ID(auto increment) and it had 5 rows so far. If I was to delete ID #3, then add one, the ID would start off at 6 and not replace the 3. My question is, how would I replace that 3? For example: Before: ID # 1 2 3 (GETS Deleted) 4 5 After: ID # 1 2 4 5 6 How would I update the ID's before and after so it goes in order, not skipping any numbers. Did I make sense o.0? Thank You! :) Quote Link to comment Share on other sites More sharing options...
luca200 Posted June 4, 2008 Share Posted June 4, 2008 What you want to do has no sense. Usually you don't have any reason to do this. And if you have some, you have to use another field and handle it "by hand". A primary key cannot work that way Quote Link to comment Share on other sites More sharing options...
Nexy Posted June 4, 2008 Author Share Posted June 4, 2008 Aww, thanks for the reply. It wasn't that important, just that on my site I have ID echo and it looks weird when it shows 1 2 5 6 9. Or some other order. But if it can't be done by coding, that's all right. Thank You! Quote Link to comment Share on other sites More sharing options...
fenway Posted June 4, 2008 Share Posted June 4, 2008 It wasn't that important, just that on my site I have ID echo and it looks weird when it shows 1 2 5 6 9. You can number your results in PHP with a simple counter... that's not what UIDs should be used for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.