Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个关于mysql排序的问题。我有一个包含这样数据的数据库字段1,6,3,8,4。我分解了这个字段值并对另一个表进行了自定义查询:WHERE id='1' or id='6' or id='3'....
1,6,3,8,4
WHERE id='1' or id='6' or id='3'...
它工作正常,但结果是ASC by id。有没有办法让结果以与查询相同的顺序出现?
ASC by id
使用子句FIELD()中的函数:ORDER BY
FIELD()
ORDER BY
ORDER BY FIElD(id, '1', '6', '3', ...);
在这里查看它的实际效果: