SQL - retain ordering based on the query params

前端 未结 7 1921
借酒劲吻你
借酒劲吻你 2021-02-10 08:34

I\'m trying to perform a SELECT with an IN clause and I would like to be able to have the results returned in the same order as the elements in my list

7条回答
  •  我在风中等你
    2021-02-10 09:00

    If you want to go with DECODE to assign a numerical sort order:

    SELECT ID FROM tbl WHERE ID IN (2,3,1)
    ORDER BY DECODE(ID, 2, 1, 3, 2, 3)
    

提交回复
热议问题