SQL 语句中按照in语句原有的顺序进行排序

Access:

select * FromWhere id in(1,5,3) order by instr(',1,5,3,',','&;id&;',')

MSSQL:

select * FromWhere id in(1,5,3) order by charindex(','+rtrim(cast(id as varchar(10)))+',',',1,5,3,')

MySQL:

select * FromWhere id in (1,5,3) order by instr(',1,5,3,',',CONCAT(',',id,','))

 

posted @   ForrestWu  阅读(660)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示