The following editor will bring you a detailed discussion of the character order of mysql order by in (recommended). The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.
Recommended related mysql video tutorials: "mysql tutorial"
//MySQL 语句SELECT * FROM `MyTable`WHERE `id` IN (11,1,111) ORDER BY FIELD(`id`, 11,1,111);
laravel framework
$ids = array(1,17,2); $ids_ordered = implode(',', $itemIds); $items = static::whereIn('id', $ids)->orderByRaw(DB::raw("FIELD(id, $ids_ordered)"))->get();
The above is the detailed content of Character order of order by in in mysql (recommended). For more information, please follow other related articles on the PHP Chinese website!