In fact, it orders the comparison result, which is a logical value of 0 or 1. The resulting code is something like (pseudocode):
ORDER BY CASE whatever = 3 THEN 1 ELSE 0 ASC, CASE whatever = 4 THEN 1 ELSE 0 ASC
What ultimately comes (if the value is in the list)
ORDER BY 0,0,1 ORDER BY 0,1,0
and if the value is not in the list:
ORDER BY 0,0,0
Values โโthat are not included in the list are treated with the same value and are not ordered, and the values โโin the list are ordered depending on the position in the list.
You can replace this with ORDER BY FIELD(whatever, 3,4,6) ( documentation )
Maxim Krizhanovsky
source share