MySQL ordering results by specific field values

by Sasikumar 2013-10-21 16:09:53

To order the values of a mysql result by a specific field value
We can use the following query
SELECT name, species FROM `pet` ORDER BY FIELD(species, 'dog','cat','snake','bird'), name ASC
Output:









NameSpecies
Bowserdog
Buffydog
Fangdog
Clawscat
Fluffycat
Slimsnake
Chirpybird
Whistlerbird
716
like
0
dislike
0
mail
flag

You must LOGIN to add comments