custom ORDER BY order in mySQL

- Posted in SQL by

custom ORDER BY order in mySQL multi field sorting

ORDER BY `ID`,
         CASE `Language`
         WHEN 'ENU' THEN 1
         WHEN 'JPN' THEN 2
         WHEN 'DAN' THEN 3
         END

add default data

ORDER BY `ID`,
         CASE `Language`
         WHEN 'ENU' THEN 1
         WHEN 'JPN' THEN 2
         WHEN 'DAN' THEN 3
         ELSE 4
         END,
         `Language`
)

source _https://stackoverflow.com/questions/9378613/how-to-define-a-custom-order-by-order-in-mysql

Tags: