读书人

50分怪有关问题UP有分!SQL语句

发布时间: 2011-12-28 22:45:21 作者: rapoo

50分怪问题,UP有分!SQL语句
现有这样一条SQL语句:select * from question where qt_id in (26,1,2,12,19)
得出来的表的顺序是按qt_id的从小到大顺序排的,可是我想得到的顺序和括号中的顺序一样(就是表中行按qt_id=26,1,2,12,19这样的顺序),请大家指教!

[解决办法]
有,修改下,更保些。


select * from question where qt_id in (26,1,2,12,19) order by CharIndex( ', ' + Cast(qt_id As Varchar) + ', ', ',26,1,2,12,19, ')

读书人网 >asp.net

热点推荐