//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 的字符順序(推薦)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持。