I have this MySql query:
SELECT * FROM `tbl_prods`
WHERE `id` IN ('58', '169', '166', '496', '24', '28')
ORDER BY FIND_IN_SET(`id`, '58, 169, 开发者_运维知识库166, 496, 24, 28')
the result is weird:
24
28
166
169
496
58
I can't figure out how to return the exact order by my FIND_IN_SET
any ideas where I am doing wrong?
You should not have spaces in
'58, 169, 166, 496, 24, 28'
Change it to
'58,169,166,496,24,28'
Use FIELD
instead of FIND_IN_SET
:
SELECT * FROM `tbl_prods`
WHERE `id` IN ('58', '169', '166', '496', '24', '28')
ORDER BY FIELD(`id`, '58', '169', '166', '496', '24', '28')
精彩评论