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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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; Quote Link to comment 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. 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.