mysql写法
SELECT * FROM table WHERE id IN (6,5,1,4) ORDER BY FIELD(id,6,5,4,1);
SELECT * FROM table WHERE id IN (6,5,1,4) ORDER BY INSTR(',6,5,1,4,',CONCAT(',',id,','));
sqlite写法
SELECT * FROM table WHERE id IN('6','5','1','4') ORDER BY INSTR('6,5,1,4',id);
oracle写法
SELECT * FROM table WHERE id IN (6,5,1,4) ORDER BY INSTR('6,5,1,4',id);
sqlserver写法
SELECT * FROM table WHERE id IN (6,5,1,4) ORDER BY CHARINDEX(','+ id +',', ',6,5,1,4,');
Sql查询按照in语句的顺序排列
最新推荐文章于 2024-08-25 22:36:40 发布