MySQL in语句排序

2020-08-14 15:40:37 浏览数 (1)

//方法一

SELECT * FROM tablename WHERE id IN(2,3,1) ORDER BY INSTR(',"2,3,1",',CONCAT(',',id,','));

//方法二

SELECT * FROM tablename WHERE id IN(2,3,1) ORDER BY FIND_IN_SET(id,"2,3,1");

//方法三

SELECT * FROM tablename WHERE id IN (2,3,1) ORDER BY FIELD(id,"2,3,1");

0 人点赞