SELECT * FROM `fz_users` WHERE `id` in ('6', '1', '30', '34', '11', '3', '2', '7', '4', '24', '221')
我正在使用此查询来显示用户数据和6,1,30 ....是用户的ID但我的问题是我需要按照我给它的相同顺序即6,1 ,30,34,11,3,2
答案 0 :(得分:4)
尝试
SELECT * FROM your_table
WHERE id IN ('6', '1', '30', '34', '11', '3', '2', '7', '4', '24', '221')
ORDER BY FIELD(id,'6', '1', '30', '34', '11', '3', '2', '7', '4', '24', '221');