日期:2014-05-16  浏览次数:20580 次

oracle 查询in操作 查询结果按in集合顺序显示

?问题如下:

select?*?from?tfm_services?t?where?t.service_name?in?('QueryAdviceConfigService'
,'ResetAdviceListState'????
,'CancelAdviceListState'
,'GetSMSCharLimit'
,'SendSMSService'
,'AddAdviceType'
,'ModAdviceType'
,'DelAdviceType'
,'DelAdviceTypeLang'
,'AddAdviceTypeLang');

?

查询出来的结果如何按照我传递参数的顺序显示出来,而不是按照service_name的首字母顺序排列

?

有一个办法,不过比较麻烦。

SQL如下:

?

select * from tfm_services t where t.service_name in (

'QueryAdviceConfigService'

,'ResetAdviceListState' ? ?

,'CancelAdviceListState'

,'GetSMSCharLimit'

,'SendSMSService'

,'AddAdviceType'

,'ModAdviceType'

,'DelAdviceType'

,'DelAdviceTypeLang'

,'AddAdviceTypeLang')

ORDER BY decode(t.service_name,'QueryAdviceConfigService',1,

'ResetAdviceListState',2,

'CancelAdviceListState',3,

'GetSMSCharLimit',4,

'SendSMSService',5

,'AddAdviceType',6

,'ModAdviceType',7

,'DelAdviceType',8

,'DelAdviceTypeLang',9);