[SQL ] 請問有關order in的問題~

看板Database作者 (陽光阿宅)時間14年前 (2012/03/02 10:49), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
資料庫是ms sqlserver 狀況是這樣的, 我下了一個查詢句 select * from reader where id in (3,4,1,2,9,5) 請問 我要如何使結果的順序 按照我 in 裡面的順序出現呢 我想要的結果是: reader: id, name --------- 3 namea 4 nameb 1 namec 2 named 9 namee 5 namef 感謝回答! 自問自答, 已解決了 最後是使用 order by case when id=3 then 1 when id=4 then 2 ... end end -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.130.139.12 ※ 編輯: drinks 來自: 220.130.139.12 (03/02 11:41)
文章代碼(AID): #1FK3LLmZ (Database)