where in 排序自动问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 01:56:38
用WHERE IN查询多个字段的时候,结果会按照ID排序,
有没有方法让其按照查找的字段顺序排序呢?
例如:
where id in('1','3','2','5','4')
然后查出来的是
1
3
2
5
4
因为查哪个字段是不确定的,不能用别的列来ORDER BY
高手给个解决方法~~~谢谢

如果象你所说的字段顺序排序,其实很简单,SELECT 字段1,字段2,字段3........fron 表名 WHERE ID IN(......)

select *
from biao
where id in(select id from biao order by 你确定顺序的字段)

where id in('1','3','2','5','4')
order by id asc

select id from 表名 where in ('1','3','2','5','4') order by id