详谈mysql order by in 的字符顺序(推荐)
程序员文章站
2023-11-14 14:57:52
//mysql 语句select * from `mytable`where `id` in (11,1,111) order by field(`id`, 11,...
//mysql 语句select * from `mytable`where `id` in (11,1,111) order by field(`id`, 11,1,111);
laravel 框架
$ids = array(1,17,2); $ids_ordered = implode(',', $itemids); $items = static::wherein('id', $ids)->orderbyraw(db::raw("field(id, $ids_ordered)"))->get();
以上这篇详谈mysql order by in 的字符顺序(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。