Detailed explanation of the order of Mysql query results according to the order of ID in in() Example code: <select id="queryGBStyleByIDs" resultMap="styleMap"> select style_num_id ,style_id,style_title,style_pic FROM gb_style where online = 1 AND is_hide = 0 and style_num_id in <foreach collection="styleNumIDs" item="styleNumId" separator="," open="(" close=")"> #{styleNumId} </foreach> ORDER BY FIELD <foreach collection="styleNumIDs" item="styleNumId" separator="," open="(style_num_id," close=")"> #{styleNumId} </foreach> </select> The final output sql is as follows: select style_num_id ,style_id,style_title,style_pic FROM gb_style where online = 1 AND is_hide = 0 and style_num_id in (1,3,2,5) order by field (style_num_id,1,3,2,5); If you have any questions, please leave a message or come to the community to discuss. Thank you for reading and I hope it can help you. Thank you for your support of this site! You may also be interested in:
|
<<: One question to understand multiple parameters of sort command in Linux
>>: Detailed explanation of CocosCreator message distribution mechanism
Vue $http get and post request cross-domain probl...
By default, the width and height of the table are...
Due to work reasons, it is often not possible to ...
How to install flash in Linux 1. Visit the flash ...
1. Problem Description root@mysqldb 22:12: [xucl]...
MySQL installation (4, 5, 6 can be omitted) State...
This article example shares the specific code of ...
KVM stands for Kernel-based Virtual Machine, whic...
Table of contents Overview 1. Hook calling order ...
A singly linked list can only be traversed from t...
Table of contents Native JS How to send a get req...
Table of contents 1. System Information 2. Shutdo...
background In order to support Docker containeriz...
Table of contents Docker images What is a mirror?...
I worked in operations and maintenance for two ye...