Home > Database > Mysql Tutorial > body text

Character order of order by in in mysql (recommended)

PHPz
Release: 2019-02-28 17:57:00
Original
6846 people have browsed it

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);
Copy after login

laravel framework

$ids = array(1,17,2);
$ids_ordered = implode(',', $itemIds);
$items = static::whereIn('id', $ids)->orderByRaw(DB::raw("FIELD(id, $ids_ordered)"))->get();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template