Ordering by the order of values in a SQL IN() clause

前端 未结 13 960
旧巷少年郎
旧巷少年郎 2020-11-22 04:12

I am wondering if there is away (possibly a better way) to order by the order of the values in an IN() clause.

The problem is that I have 2 queries, one that gets al

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 04:40

    SELECT ORDER_NO, DELIVERY_ADDRESS 
    from IFSAPP.PURCHASE_ORDER_TAB 
    where ORDER_NO in ('52000077','52000079','52000167','52000297','52000204','52000409','52000126') 
    ORDER BY instr('52000077,52000079,52000167,52000297,52000204,52000409,52000126',ORDER_NO)
    

    worked really great

提交回复
热议问题