SQLite and custom order by

前端 未结 3 1561
无人共我
无人共我 2020-11-29 04:09

I have a table with categories:

ID  Category
\"1\",\"Baking\"   
\"3\",\"Family\"   
\"4\",\"Entertaining\"   
\"5\",\"Children\"   
\"6\",\"Desserts\"   
<         


        
3条回答
  •  情歌与酒
    2020-11-29 04:57

    A second way of doing it (the first one being with CASE WHEN ... THEN END as already stated in other answers) is:

    ORDER BY ID=4 DESC,
             ID=3 DESC,
             ID=1 DESC,
             ID=5 DESC,
             ID=6 DESC
    

提交回复
热议问题