Detailed discussion of the character order of mysql order by in (recommended)

Detailed discussion of the character order of mysql order by in (recommended)
//MySQL statement 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 article discusses the character sequence of mysql order by in (recommended) in detail. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL Order by statement usage and optimization detailed explanation
  • In-depth analysis of the order by and group by sequence issues in MySQL
  • How to use union and order by at the same time in MySQL
  • MySQL Order By Syntax Introduction
  • MySQL Order By Index Optimization Method
  • MySQL order by performance optimization method example
  • MySQL Order By Multi-Field Sorting Rules Code Example
  • Implementation analysis of MySQL ORDER BY
  • MySQL Order By Rand() Efficiency Analysis
  • Summary of three ways to implement ranking in MySQL without using order by

<<:  Reasons and solutions for failure of dynamically added routing pages in Vue when refreshing

>>:  Detailed explanation of the application of Docker Swarm in continuous integration testing

Recommend

Getting Started with MySQL - Concepts

1. What is it? MySQL is the most popular relation...

Use the more, less, and cat commands in Linux to view file contents

In Linux, the commands cat, more, and less can al...

Linux disk space release problem summary

The /partition utilization of a server in IDC is ...

Use of Vue3 table component

Table of contents 1. Ant Design Vue 1. Official w...

A brief discussion on the implementation principle of Webpack4 plugins

Table of contents Preface know Practice makes per...

Six weird and useful things about JavaScript

Table of contents 1. Deconstruction Tips 2. Digit...

Mysql optimization Zabbix partition optimization

The biggest bottleneck of using zabbix is ​​the d...

Why MySQL does not recommend using subqueries and joins

To do a paginated query: 1. For MySQL, it is not ...

A great collection of web standards learning resources

These specifications are designed to allow for bac...

Detailed explanation of CSS text decoration text-decoration &amp; text-emphasis

In CSS, text is one of the most common things we ...

Implementing CommonJS modularity in browsers without compilation/server

Table of contents introduction 1. What is one-cli...

In IIS 7.5, HTML supports the include function like SHTML (add module mapping)

When I first started, I found a lot of errors. In...

Practical tutorial on modifying MySQL character set

Preface: In MySQL, the system supports many chara...

Detailed explanation of Vue's calculated properties

1. What is a calculated attribute? In plain words...