WHERE `field` IN () 查询结果排序问题

-- 查询结果按照“IN ()”里面的id顺序排列
SELECT
  `*`
FROM
  `表名`
WHERE
  `id` IN (12, 13, 50, 31, 27)
ORDER BY
  INSTR('12, 13, 50, 31, 27', `id`);

Copyright © 2023 码农人生. All Rights Reserved