garyed Posted June 13, 2011 Share Posted June 13, 2011 I have a table with a bunch of records that each have a unique id number as one of the fields. Since I added things hap-hazardly they are all over the place order wise. Is there a command to update or alter the table where the records could be moved so that they go from lowest to highest using the id number? Quote Link to comment https://forums.phpfreaks.com/topic/239269-change-oder-of-records-in-table/ Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 you would want to use the ALTER TABLE clause, use as follows. $query = mysql_query("ALTER TABLE table_name ORDER BY id DESC|ASC"); for further syntax examples visit http://dev.mysql.com/doc/refman/5.1/en/alter-table.html Quote Link to comment https://forums.phpfreaks.com/topic/239269-change-oder-of-records-in-table/#findComment-1229227 Share on other sites More sharing options...
garyed Posted June 13, 2011 Author Share Posted June 13, 2011 Thanks, thats exactly what I needed. I also just found the answer using phpmyadmin too. Quote Link to comment https://forums.phpfreaks.com/topic/239269-change-oder-of-records-in-table/#findComment-1229233 Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 glad i could help, please mark this thread as solved, lower left hand of page. Quote Link to comment https://forums.phpfreaks.com/topic/239269-change-oder-of-records-in-table/#findComment-1229241 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.