SQLite和自定义顺序

前端之家收集整理的这篇文章主要介绍了SQLite和自定义顺序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个表与类别:
ID  Category
"1","Baking"   
"3","Family"   
"4","Entertaining"   
"5","Children"   
"6","Desserts"

现在我想订购select语句的结果

ID  Category
"4","Entertaining"   
"3","Family"  
"1","Baking"   
"5","Desserts"

例如。在MysqL中,你会这样做:

SELECT * FROM CATEGORIES ORDER BY FIELD (ID,4,3,1,5,6);

你会怎么做在sqlite虽然?我没有“order by”字段。

ORDER BY 
  CASE ID
    WHEN 4 THEN 0
    WHEN 3 THEN 1
    WHEN 1 THEN 2
    WHEN 5 THEN 3
    WHEN 6 THEN 4
  END
原文链接:https://www.f2er.com/sqlite/198119.html

猜你在找的Sqlite相关文章