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

    <small id='wQL2J'></small><noframes id='wQL2J'>

  • <legend id='wQL2J'><style id='wQL2J'><dir id='wQL2J'><q id='wQL2J'></q></dir></style></legend>

        • <bdo id='wQL2J'></bdo><ul id='wQL2J'></ul>
        <tfoot id='wQL2J'></tfoot>
      1. Mysql 统计子串的实例数,然后按顺序排序

        Mysql count instances of substring, then order by(Mysql 统计子串的实例数,然后按顺序排序)

      2. <legend id='iRXHC'><style id='iRXHC'><dir id='iRXHC'><q id='iRXHC'></q></dir></style></legend>
        • <bdo id='iRXHC'></bdo><ul id='iRXHC'></ul>

          <small id='iRXHC'></small><noframes id='iRXHC'>

          1. <tfoot id='iRXHC'></tfoot>

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

                • 本文介绍了Mysql 统计子串的实例数,然后按顺序排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我在 mySQL 中遇到如下问题:

                  I have a problem in mySQL that goes as follows:

                  • 计算 mySQL 数据库中字符串字段中子字符串的实例
                  • 按该子字符串 (DESC) 的出现次数对结果进行排序

                  除了基本的查询之外,我从未做过任何事情.我在其他地方找不到解决方案.

                  I have never done anything other than rudimentary queries.. I can't find a solution elsewhere.

                  推荐答案

                  SELECT (CHAR_LENGTH(str) - CHAR_LENGTH(REPLACE(str, substr, ''))) / CHAR_LENGTH(substr) AS cnt
                  ...
                  ORDER BY cnt DESC
                  

                  是的,看起来很臃肿,但没有任何其他可能的解决方案.

                  Yep, looks bloated but afaik there is no any other possible solution.

                  mysql> select (CHAR_LENGTH('asd') - CHAR_LENGTH(REPLACE('asd', 's', ''))) / CHAR_LENGTH('s');
                  +-----------------------------------------------------------------+
                  | (CHAR_LENGTH('asd') - CHAR_LENGTH(REPLACE('asd', 's', ''))) / CHAR_LENGTH('s') |
                  +-----------------------------------------------------------------+
                  |                                                          1.0000 |
                  +-----------------------------------------------------------------+
                  1 row in set (0.00 sec)
                  
                  
                  
                  mysql> select host, (CHAR_LENGTH(host) - CHAR_LENGTH(REPLACE(host, 'l', ''))) / CHAR_LENGTH('l') AS cnt from user;
                  +-----------+--------+
                  | host      | cnt    |
                  +-----------+--------+
                  | 127.0.0.1 | 0.0000 |
                  | honeypot  | 0.0000 |
                  | honeypot  | 0.0000 |
                  | localhost | 2.0000 |
                  | localhost | 2.0000 |
                  +-----------+--------+
                  5 rows in set (0.00 sec)
                  

                  这篇关于Mysql 统计子串的实例数,然后按顺序排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
                  MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
                  Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
                  How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
                  Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
                  Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)

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

                      • <bdo id='uMU22'></bdo><ul id='uMU22'></ul>
                      • <legend id='uMU22'><style id='uMU22'><dir id='uMU22'><q id='uMU22'></q></dir></style></legend>

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