The plurality of sort fields mysql fixed sequence

4,5,7,1,2,3 1. Sort the order cstate

sql statement:

SELECT c.cstate,c.mc_1
from
s_c c
where
c.cstate in(1,2,3,4,5,7)
ORDER BY FIELD(c.cstate,4,5,7,1,2,3);
Here Insert Picture Description

The sequence cstate 3,2,1 sort of 4,5,7,1,2,3 and mc_1

Statement:

SELECT c.cstate,c.mc_1
from
s_c c
where
c.cstate in(1,2,3,4,5,7)
ORDER BY FIELD(c.cstate,4,5,7,1,2,3),FIELD(c.mc_1,3,2,1);

Released seven original articles · won praise 0 · Views 94

Guess you like

Origin blog.csdn.net/qq_39052099/article/details/104319716