random1 Posted August 18, 2008 Share Posted August 18, 2008 Hi All, Is there a way in MYSQL to switch or rotate records based on an index or primary key? i.e. PK| Name| Description| ----------------------------- 1 test1 desc1 2 test2 desc2 updates to... PK| Name| Description| ----------------------------- 1 test2 desc2 2 test1 desc1 Ultimately I am looking to sort the data itself in the database with an update sequence so I have the ability to sort by Name A-Z. Link to comment https://forums.phpfreaks.com/topic/120180-how-to-switchrotate-records/ Share on other sites More sharing options...
random1 Posted August 18, 2008 Author Share Posted August 18, 2008 So far I have: UPDATE table1 SET table1_ID = table1_ID ORDER BY table1_name DESC; But not working Link to comment https://forums.phpfreaks.com/topic/120180-how-to-switchrotate-records/#findComment-619111 Share on other sites More sharing options...
Mchl Posted August 18, 2008 Share Posted August 18, 2008 Why would you do it? You shouldn't. Link to comment https://forums.phpfreaks.com/topic/120180-how-to-switchrotate-records/#findComment-619119 Share on other sites More sharing options...
Hooker Posted August 18, 2008 Share Posted August 18, 2008 You can only set the order the result set, ie. SELECT * FROM table1 ORDER BY table1.name DESC; Link to comment https://forums.phpfreaks.com/topic/120180-how-to-switchrotate-records/#findComment-619281 Share on other sites More sharing options...
fenway Posted August 20, 2008 Share Posted August 20, 2008 You can only set the order the result set Strictly speaking, you can use ALTER TABLE to order rows, but that's usually meant for very expensive operations or on read-only tables. Link to comment https://forums.phpfreaks.com/topic/120180-how-to-switchrotate-records/#findComment-620672 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.