MySQL: ORDER BY conditions

Gut zu wissen:

To get the sorting in the order you want, use your conditions in the ORDER BY, but use DESC after them.

SELECT *
FROM person
WHERE (condition1 OR condition2 OR condition3)
AND maintable.status = static
ORDER BY
 condition1 DESC,
 condition2 DESC,
 condition3 DESC

Also z.B.

SELECT *
FROM person
WHERE (Country = 'de' OR Country = 'es' OR Country = 'fr')
AND maintable.status = static
ORDER BY
 Country = 'de' DESC,
 Country = 'es' DESC,
 Country = 'fr' DESC

Possibly related posts (automatically generated)