Rumah > Artikel > pangkalan data > mysql中order by in 的字符顺序(推荐)
下面小编就为大家带来一篇详谈mysql order by in 的字符顺序(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
相关mysql视频教程推荐:《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();
Atas ialah kandungan terperinci mysql中order by in 的字符顺序(推荐). Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!