详谈mysql order by in 的字符顺序(推荐)
时间:2021-10-02 07:27:00|栏目:Mysql|点击: 次
//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
下一篇:MySQL4 File ‘c:\mysql\share\charsets\?.conf’ not found (Errcode: 22)的解决方法
本文标题:详谈mysql order by in 的字符顺序(推荐)
本文地址:http://www.codeinn.net/misctech/178459.html