Order MySQL Query by User Defined Order Using the Field() Function

I was writing a MySQL database query and ran into an interesting challenge where my result set needed to be ordered in a predefined order to meet business logic requirements. Typically the ORDER BY clause will sort using numeric or alphabetical order. This is pretty limiting if you want to define an enumeration of values that should provide the sort order. more…