MySQL Custom Sort

Here’s something neat. If you want your SQL results in an order that’s not alphabetical or numerical, this little bit of code will allow you to specify what order you want your fields to appear.

Note that these are not in alphabetical order. You can still add other sort fields before and after this case. Pretty neat!

4 Responses

  1. Bryan

    Great tip, this is exactly what I was looking for! I just wanted to pull one category to the top of the list that fell in the middle in alpha sort and this tip worked perfectly.

    Thanks for posting, I have learned MySQL through a very incremental approach and this is a great addition to my arsenal.

    Regards,
    Bryan

  2. Jamie Tibbetts

    Genius. Thanks.

  3. Ibrahim Lawal

    This is superb! Thansk for sharing!!

  4. Dave Conan

    thanks, never thought about it before, genius,

Write a Comment