order by field 和 order by INSTR 自定義排序

select * from table where id in (5,3,6,1) order by field(排序字段,5,3,6,1)

記錄按照5,3,6,1的順序返回

如果沒有order by field 將按 1,3,5,6的順序返回


或者


select * from table where id in (5,3,6,1) order by INSTR('5,3,6,1',排序字段)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章