Fork me on GitHub
摘要: 做网站的时候需要一个需求,需要按照指定的ID获取数据库中的数据,返回数据的顺序要和指定ID的顺序相同,数据库是SQL Server的,下面的代码是在网上找来的,SQL server的已经测试过,可以满足要求。Access:select * From 表 Where id in(1,5,3) order by instr(',1,5,3,',','&id&',')MSSQL:select * From 表 Where id in(1,5,3) order by charindex(','+rtrim(cast(id 阅读全文
posted @ 2011-10-31 18:14 磊哥|www.javacn.site 阅读(1989) 评论(0) 推荐(1) 编辑