mysql中order by in 的字符顺序(推荐)
发表时间:2023-09-09 来源:明辉站整理相关软件相关文章人气:
[摘要]下面小编就为大家带来一篇详谈mysql order by in 的字符顺序(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧//MySQL 语句SELECT * FROM `MyTable`WHERE `id` IN (11,1,111) ORDER BY FI...
下面小编就为大家带来一篇详谈mysql order by in 的字符顺序(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
//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 的字符顺序(推荐)的详细内容,更多请关注php中文网其它相关文章!
学习教程快速掌握从入门到精通的SQL知识。