1. <small id='sZnKj'></small><noframes id='sZnKj'>

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

      <tfoot id='sZnKj'></tfoot>

      1. 在 MYSQL 的子查询中使用 LIMIT 关键字的替代方法

        时间:2023-06-02

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

                  <small id='8dHtq'></small><noframes id='8dHtq'>

                  <tfoot id='8dHtq'></tfoot>
                  本文介绍了在 MYSQL 的子查询中使用 LIMIT 关键字的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含以下列的表 TEST:

                  I have a table TEST with the following columns :

                  code_ver (VARCHAR)
                  suite (VARCHAR)
                  date (DATE)
                  

                  现在我想选择具有不同值 code_ver & 的 10 行code_ver NOT LIKE '%DevBld%' 按日期降序排序.

                  Now I want to select 10 rows with a distinct value of code_ver & code_ver NOT LIKE '%DevBld%' sorted by date desc.

                  所以我写了以下查询:

                  select * 
                    from test 
                   where code_ver IN (select DISTINCT code_ver 
                                        from test 
                                       where code_ver NOT LIKE '%DevBld%' 
                                       ORDER by date DESC LIMIT 10);
                  

                  这个查询应该可以正常工作,但我的 MySQL 版本说:

                  This query should ideally work, but my version of MySQL says :

                  此版本的 MySQL 尚不支持 'LIMIT &在/所有/任何/一些子查询'

                  This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

                  有人可以建议我替代此查询吗?

                  Can someone suggest me an alternative to this query?

                  推荐答案

                  你得到的错误并不完全是因为 MySQL 的版本.我认为所有版本都支持.您必须更改 LIMIT 10 位置并将其放在)"之后.请让我知道这对你有没有用.我在我的上运行了波纹管,它工作正常.

                  The error you are getting is not exactly because of the version of MySQL. I think all versions support that. You have to change the LIMIT 10 place and place it after ")". Let me know if it works for you. I ran the bellow one on mine and it works.

                  例如

                  SELECT * FROM test where name IN (
                             SELECT DISTINCT name 
                             FROM projects 
                             WHERE name NOT LIKE "%DevBld%"  
                             ORDER by date_created DESC
                   ) LIMIT 10;
                  

                  更新:试试下面的一个,这样顺序就行了:

                  Update: Try the one below, this way order would work:

                   SELECT * FROM  automation.e2e_projects WHERE name IN (
                         SELECT DISTINCT name 
                         FROM automation.e2e_projects
                         WHERE name NOT LIKE "%DevBld%"
                   ) ORDER by date_created DESC LIMIT 10;
                  

                  这篇关于在 MYSQL 的子查询中使用 LIMIT 关键字的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 MySQL 中正确使用 CASE..WHEN 下一篇:以整数形式获取 MySQL 中两个日期之间的年差

                  相关文章

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

                        <bdo id='HNcrw'></bdo><ul id='HNcrw'></ul>
                    1. <tfoot id='HNcrw'></tfoot>