MySQL - ORDER BY values within IN()

前端 未结 6 1903
时光说笑
时光说笑 2020-11-27 10:46

I\'m hoping to sort the items returned in the following query by the order they\'re entered into the IN() function.

INPUT:

SELECT id         


        
6条回答
  •  清歌不尽
    2020-11-27 11:33

    just use

    order by INSTR( ',B,C,D,A,' ,  concat(',' , `field`, ',' ) )
    

    avoid the situation like

     INSTR('1,2,3,11' ,`field`) 
    

    will end with unordered result row : 1 and 11 alternant

提交回复
热议问题