实现SQL语句中,按照in 中的顺序排序的方法
来源:phperz.com 作者:phperz.com 发布时间:2011-08-13
如何让sql 按照 in中的顺序返回结果 oracle写法: Select * from web_pics where id In (8234030,8234025,8234036) order By instr(',8234030,8234025,8234036,',',' || id || ',' ) sqlserver写法: Select * From Product Where id in (1,1588,15782,9887,54) Order
如何让sql 按照 in中的顺序返回结果
oracle写法:
Select * from web_pics where id In (8234030,8234025,8234036) order By instr(',8234030,8234025,8234036,',',' || id || ',' )
sqlserver写法:
Select * From Product Where id in (1,1588,15782,9887,54) Order By charindex(','+ id +',', ',1,1588,15782,9887,54,')
延伸阅读:PHP实现常见排序算法PHP数组学习排序全接触php冒泡算法对数组排序SQL中对where in 排序问题Mysql group by 排序相关问题