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

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

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

      <legend id='LzC6O'><style id='LzC6O'><dir id='LzC6O'><q id='LzC6O'></q></dir></style></legend>

      MYSQL Left Join 如何选择 NULL 值?

      时间:2023-10-09

          <tbody id='TeDaU'></tbody>
      • <small id='TeDaU'></small><noframes id='TeDaU'>

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

                <tfoot id='TeDaU'></tfoot>
              1. <legend id='TeDaU'><style id='TeDaU'><dir id='TeDaU'><q id='TeDaU'></q></dir></style></legend>
                本文介绍了MYSQL Left Join 如何选择 NULL 值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我上一个关于 MySQL 中表连接的问题的后续问题

                This is a follow up question to my last question about table joins in MySQL

                我需要能够从左连接表中选择 NULL 值.

                I need to be able to select the NULL values from the left joined table.

                这是我的加入:

                table1.id | table1.name | table2.id | table2.surname
                        1 |        John |         1 |            Doe
                        2 |     Michael |         2 |       Anderson
                        3 |        Anna |      NULL |           NULL
                        4 |         Sue |      NULL |           NULL
                

                我想select WHERE table2.surname = NULL,但是这样的查询不起作用:

                I would want to select WHERE table2.surname = NULL, but a query like this doesn't work:

                SELECT table1.*,table2.*
                FROM table1
                LEFT JOIN table2
                    ON table1.id=table2.id
                WHERE table2.surname=NULL
                

                我可以稍微理解它背后的逻辑,没有给我任何结果,但必须有一种方法来获取它们的结果?

                I can somewhat understand the logic behind it not giving me any results, but there must be a way to grab them results?

                感谢任何帮助.

                推荐答案

                要比较 NULL 值,您必须使用 IS NULL 谓词,如下所示:

                To compare NULL values you have to use the IS NULL predicate, like this:

                SELECT table1.*, table2.*
                FROM table1
                LEFT JOIN table2 ON table1.id=table2.id
                WHERE table2.surname IS NULL
                

                这篇关于MYSQL Left Join 如何选择 NULL 值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在不同的列上两次加入同一个表 下一篇:MySQL删除左连接上的重复列,3个表

                相关文章

                <tfoot id='bobZU'></tfoot>

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

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

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

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