<tfoot id='CXtAB'></tfoot>

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

    4. “子查询返回多于1行"的解决方案错误

      Solution to quot;subquery returns more than 1 rowquot; error(“子查询返回多于1行的解决方案错误)

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

              <bdo id='crOVV'></bdo><ul id='crOVV'></ul>
              <tfoot id='crOVV'></tfoot>

                  <tbody id='crOVV'></tbody>

              • <legend id='crOVV'><style id='crOVV'><dir id='crOVV'><q id='crOVV'></q></dir></style></legend>
                本文介绍了“子查询返回多于1行"的解决方案错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个返回多行的查询,还有另一个查询,我想在其中将条件设置为来自这些多行的值之一,所以基本上我希望子查询看起来像这样:

                I have one query that returns multiple rows, and another query in which I want to set criteria to be either one of values from those multiple rows , so basicly I want the subquery to look something like this:

                select * 
                from table
                where id= (multiple row query);
                

                其中 multiple row query 返回多行.因此,如果这些行的值是 1、2、3,那么我想将 id 设置为 1 或 2 或 3.

                Where multiple row query returns multiple rows. So if the values from those rows are 1,2,3 then I want to set id to be 1 or 2 or 3.

                推荐答案

                = 可以在子查询只返回 1 个值时使用.

                = can be used when the subquery returns only 1 value.

                当子查询返回超过 1 个值时,您将不得不使用 IN:

                When subquery returns more than 1 value, you will have to use IN:

                select * 
                from table
                where id IN (multiple row query);
                

                例如:

                SELECT *
                FROM Students
                WHERE Marks = (SELECT MAX(Marks) FROM Students)   --Subquery returns only 1 value
                
                SELECT *
                FROM Students
                WHERE Marks IN 
                      (SELECT Marks 
                       FROM Students 
                       ORDER BY Marks DESC
                       LIMIT 10)                       --Subquery returns 10 values
                

                这篇关于“子查询返回多于1行"的解决方案错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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='TZdeo'><style id='TZdeo'><dir id='TZdeo'><q id='TZdeo'></q></dir></style></legend>

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

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

                      <bdo id='TZdeo'></bdo><ul id='TZdeo'></ul>

                            <tbody id='TZdeo'></tbody>