MySQL ORDER BY 指定字段值排序方法
有这样一个sql:
table('readsort')->where('id', 'in', '3,2,1')->select();
出来之后默认排序为id:1,2,3,现在要让他保持3,2,1排序不变,则需要:
table('readsort')->where('id', 'in', '3,2,1')->order('FIELD(id,3,2,1)')->select();
参考:
select * from test where id in (3,2,1) order by FIELD(id,3,2,1)
${content}