Skip to content


How to reorder a MySQL table following multiple columns

I usually use phpMyAdmin for uncommon queries the syntax of which I don’t know by heart, but sorting according to multiple columns doesn’t seem to be an option there.
Gladly, the syntax is really simple, it’s just an extension from the syntax to sort against a single column… So, for instance it looks like:
ALTER TABLE tableName ORDER by aColumn ASC, anotherColumn ASC, yetAnotherColumn ASC;
Quite intuitively, the sorting is done first according to the first column, then ties are sorted according to the second one, etc. As usual, “ASC” is for ascending order, and “DESC” for descending order.

Fairly trivial once you’ve figured it out, so short post this time 🙂

Posted in MySQL.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA