SELECT
u.*
FROM
users u
WHERE
u.id IN (5, 4, 1, 2, 3)
If you do it, the result is The results of the arrangement of 1, 2, 3, 4, and 5 come out, so can't we make it come out as we put it in?
mysql
It's a self-answer.
SELECT
u.*
FROM
users u
WHERE
u.id IN (5, 4, 1, 2, 3)
ORDER BY
FIELD(u.id, 5, 4, 1, 2, 3)
© 2024 OneMinuteCode. All rights reserved.