ITeye博客

让sql语句不排序,按照in语句的顺序返回结果

sjeveryday · 2013-06-20 11:11 · SQL 语句 · 数据库 · Markdown

Oracle 写法

select os.order_sn,os.erp_salenum,os.ship_name,os.taobao_ordernum
  from orders os
 where os.taobao_ordernum in ('272254116092316',
                              '228961748650514',
                              '367198169861891'
) order By instr(',272254116092316,228961748650514,367198169861891,',',' || taobao_ordernum || ',' )

sqlserver写法:

 Select * From orders Where id in (1,2,43,22,54)  Order By charindex(','+ id +',', ',1,2,43,22,54,')

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。