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

abbr mark and acronym mark

The <abbr> and <acronym> tags represen...

Centering the Form in HTML

I once encountered an assignment where I was give...

Summary of uncommon operators and operators in js

Summary of common operators and operators in java...

Detailed explanation of three methods of JS interception string

JS provides three methods for intercepting string...

MySQL dual-master (master-master) architecture configuration solution

In enterprises, database high availability has al...

How to implement Ajax concurrent request control based on JS

Table of contents Preface Ajax serial and paralle...

Simple usage example of vue recursive component

Preface I believe many students are already famil...

In-depth explanation of iterators in ECMAScript

Table of contents Preface Earlier iterations Iter...

Native JS to implement click number game

Native JS implements the click number game for yo...

How to install MySQL 8.0.13 in Alibaba Cloud CentOS 7

1. Download the MySQL installation package (there...

Nginx cache files and dynamic files automatic balancing configuration script

nginx Nginx (engine x) is a high-performance HTTP...

Specific use of MySQL operators (and, or, in, not)

Table of contents 1. Introduction 2. Main text 2....

Best Practices for Sharing React Code

When any project develops to a certain complexity...

Detailed explanation of several methods of deduplication in Javascript array

Table of contents Array deduplication 1 Double-la...

How to embed other web pages in a web page using iframe

How to use iframe: Copy code The code is as follo...