SQL语句如下:
select * from pdt_Music where MusicID in(1,2,3,4,5,6,7,8,9)
order by CHARINDEX(RTRIM(CAST(MusicID as NCHAR)),'5,2,8,1,3,4,6,7,9')
select * from wcm_PublishmentSystem where PublishmentSystemID in(2491,3610,2588,2629,2669)
order by charindex(','+convert(varchar,PublishmentSystemID)+',','2491,3610,2588,2629,2669')
select * from wcm_PublishmentSystem Where PublishmentSystemID IN (2491,3610,2588,2629,2669)
order by CHARINDEX(RTRIM(CAST(PublishmentSystemID as NCHAR)),'2669,3610,2491,2588,2629')
本文介绍了三种使用SQL进行数据查询的方法,包括如何通过特定ID集合筛选记录并按预设顺序排序。这些示例展示了如何灵活运用CHARINDEX函数实现自定义排序。

1060

被折叠的 条评论
为什么被折叠?



