• <small id='PElpO'></small><noframes id='PElpO'>

    • <bdo id='PElpO'></bdo><ul id='PElpO'></ul>

      <i id='PElpO'><tr id='PElpO'><dt id='PElpO'><q id='PElpO'><span id='PElpO'><b id='PElpO'><form id='PElpO'><ins id='PElpO'></ins><ul id='PElpO'></ul><sub id='PElpO'></sub></form><legend id='PElpO'></legend><bdo id='PElpO'><pre id='PElpO'><center id='PElpO'></center></pre></bdo></b><th id='PElpO'></th></span></q></dt></tr></i><div id='PElpO'><tfoot id='PElpO'></tfoot><dl id='PElpO'><fieldset id='PElpO'></fieldset></dl></div>

      1. <legend id='PElpO'><style id='PElpO'><dir id='PElpO'><q id='PElpO'></q></dir></style></legend>
        <tfoot id='PElpO'></tfoot>

        SQLite 和自定义顺序

        SQLite and custom order by(SQLite 和自定义顺序)
          <tbody id='KCPQy'></tbody>

          <legend id='KCPQy'><style id='KCPQy'><dir id='KCPQy'><q id='KCPQy'></q></dir></style></legend>
            <bdo id='KCPQy'></bdo><ul id='KCPQy'></ul>
            1. <small id='KCPQy'></small><noframes id='KCPQy'>

              <i id='KCPQy'><tr id='KCPQy'><dt id='KCPQy'><q id='KCPQy'><span id='KCPQy'><b id='KCPQy'><form id='KCPQy'><ins id='KCPQy'></ins><ul id='KCPQy'></ul><sub id='KCPQy'></sub></form><legend id='KCPQy'></legend><bdo id='KCPQy'><pre id='KCPQy'><center id='KCPQy'></center></pre></bdo></b><th id='KCPQy'></th></span></q></dt></tr></i><div id='KCPQy'><tfoot id='KCPQy'></tfoot><dl id='KCPQy'><fieldset id='KCPQy'></fieldset></dl></div>
                • <tfoot id='KCPQy'></tfoot>
                  本文介绍了SQLite 和自定义顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有类别的表格:

                  I have a table with categories:

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

                  现在我想将select语句的结果排序为

                  Now I would like to order the result of the select statement to

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

                  例如.在 MySQL 中,你会这样做:

                  for example. In MySQL, you'd do it like this:

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

                  你会如何在 SQLite 中做到这一点?我没有order by"字段.

                  How would you do it in SQLite though? I don't have an "order by" field.

                  推荐答案

                  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
                  

                  这篇关于SQLite 和自定义顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bogus foreign key constraint fail(虚假外键约束失败)
                  how to get last insert id after insert query in codeigniter active record(如何在codeigniter活动记录中插入查询后获取最后一个插入ID)
                  Force InnoDB to recheck foreign keys on a table/tables?(强制 InnoDB 重新检查表/表上的外键?)
                  How to auto generate migrations with Sequelize CLI from Sequelize models?(如何使用 Sequelize CLI 从 Sequelize 模型自动生成迁移?)
                  Clear MySQL query cache without restarting server(无需重启服务器即可清除 MySQL 查询缓存)
                  ALTER TABLE to add a composite primary key(ALTER TABLE 添加复合主键)
                • <legend id='6GwS8'><style id='6GwS8'><dir id='6GwS8'><q id='6GwS8'></q></dir></style></legend>
                    <tbody id='6GwS8'></tbody>
                      <bdo id='6GwS8'></bdo><ul id='6GwS8'></ul>

                            <i id='6GwS8'><tr id='6GwS8'><dt id='6GwS8'><q id='6GwS8'><span id='6GwS8'><b id='6GwS8'><form id='6GwS8'><ins id='6GwS8'></ins><ul id='6GwS8'></ul><sub id='6GwS8'></sub></form><legend id='6GwS8'></legend><bdo id='6GwS8'><pre id='6GwS8'><center id='6GwS8'></center></pre></bdo></b><th id='6GwS8'></th></span></q></dt></tr></i><div id='6GwS8'><tfoot id='6GwS8'></tfoot><dl id='6GwS8'><fieldset id='6GwS8'></fieldset></dl></div>
                          1. <small id='6GwS8'></small><noframes id='6GwS8'>

                            <tfoot id='6GwS8'></tfoot>