Created
August 29, 2015 13:43
-
-
Save solepixel/7a64e28d95be9f0c13db to your computer and use it in GitHub Desktop.
Custom Sort Order in MySQL (order by case)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORDER BY CASE | |
WHEN `col` = ‘item’ THEN 1 | |
WHEN `col` = ‘thing’ THEN 2 | |
WHEN `col` = ‘stuff’ THEN 3 | |
WHEN `col` = ‘boom’ THEN 4 | |
ELSE 5 | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment