urbanscribe Posted May 24, 2006 Share Posted May 24, 2006 I feel as though I am probably overlooking something obvious here, but hopefully you guys can point it out to me. I have a few screenshots to show what I'm seeing, as it may be a little difficult to explain.I have a table that has column `ID` set for auto_increment and as the Primary Key. I put in 5 rows as can be seen [b][a href=\"http://www.lukewilkins.com/one.gif\" target=\"_blank\"]in this image[/a][/b], and the auto_increment seems to work perfectly.Now, I decide to delete the Address row (which is ID 3), and that goes smoothly. I now have [b][a href=\"http://www.lukewilkins.com/two.gif\" target=\"_blank\"]this[/a][/b].Then I decide to add a new row called Comment and it gives it the ID 6 (as it should). However, as you can see [b][a href=\"http://www.lukewilkins.com/three.gif\" target=\"_blank\"]here[/a][/b], it places it in between ID's 2 and 4 instead of at the end of the table.This result effects some of my later scripts and need to know how to have it just place it at the end of the table. Everything is done in php (not in phpMyAdmin). Is it something to do with the auto_increment or primary key? Any help would be greatly appreciated.Luke Quote Link to comment https://forums.phpfreaks.com/topic/10330-rows-being-placed-out-of-order/ Share on other sites More sharing options...
Honoré Posted May 24, 2006 Share Posted May 24, 2006 This seems fine to me.If you want the rows ordered use [code]SELECT * FROM fields_1 ORDER BY id[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10330-rows-being-placed-out-of-order/#findComment-38507 Share on other sites More sharing options...
fenway Posted May 24, 2006 Share Posted May 24, 2006 Honoré is right -- if you want the rows back in a particular order, you have to ask for it. Don't EVER rely on the internal row order, because -- as you discovered -- MySQL will generally "fill in the gaps", placing new rows where deleted rows once were (at least in MyISAM tables). Quote Link to comment https://forums.phpfreaks.com/topic/10330-rows-being-placed-out-of-order/#findComment-38599 Share on other sites More sharing options...
bobleny Posted May 24, 2006 Share Posted May 24, 2006 Yeah, I had that same issue! That might work for urbanscribe but for me it is backwards. That places them in increasing order and I require that the be in decreasing order. So, how would I do that? Quote Link to comment https://forums.phpfreaks.com/topic/10330-rows-being-placed-out-of-order/#findComment-38719 Share on other sites More sharing options...
AndyB Posted May 24, 2006 Share Posted May 24, 2006 [!--quoteo(post=376824:date=May 24 2006, 05:57 PM:name=Bob Leny)--][div class=\'quotetop\']QUOTE(Bob Leny @ May 24 2006, 05:57 PM) [snapback]376824[/snapback][/div][div class=\'quotemain\'][!--quotec--]Yeah, I had that same issue! That might work for urbanscribe but for me it is backwards. That places them in increasing order and I require that the be in decreasing order. So, how would I do that?[/quote]DESCending order ...[code]SELECT * from tablename ORDER by whatever DESC[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10330-rows-being-placed-out-of-order/#findComment-38723 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.