mysql写法
[SQL] 纯文本查看 复制代码
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写法
[SQL] 纯文本查看 复制代码
SELECT * FROM table WHERE id IN('6','5','1','4') ORDER BY INSTR('6,5,1,4',id);
oracle写法
[SQL] 纯文本查看 复制代码
SELECT * FROM table WHERE id IN (6,5,1,4) ORDER BY INSTR('6,5,1,4',id);
sqlserver写法
[SQL] 纯文本查看 复制代码
SELECT * FROM table WHERE id IN (6,5,1,4) ORDER BY CHARINDEX(','+ id +',', ',6,5,1,4,');
|