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

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

        使用 MySQL 检查空字段

        时间:2023-10-15

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

            1. <legend id='Ti0kY'><style id='Ti0kY'><dir id='Ti0kY'><q id='Ti0kY'></q></dir></style></legend>
                <bdo id='Ti0kY'></bdo><ul id='Ti0kY'></ul>

                  <tbody id='Ti0kY'></tbody>

                1. <i id='Ti0kY'><tr id='Ti0kY'><dt id='Ti0kY'><q id='Ti0kY'><span id='Ti0kY'><b id='Ti0kY'><form id='Ti0kY'><ins id='Ti0kY'></ins><ul id='Ti0kY'></ul><sub id='Ti0kY'></sub></form><legend id='Ti0kY'></legend><bdo id='Ti0kY'><pre id='Ti0kY'><center id='Ti0kY'></center></pre></bdo></b><th id='Ti0kY'></th></span></q></dt></tr></i><div id='Ti0kY'><tfoot id='Ti0kY'></tfoot><dl id='Ti0kY'><fieldset id='Ti0kY'></fieldset></dl></div>
                2. <tfoot id='Ti0kY'></tfoot>
                  本文介绍了使用 MySQL 检查空字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我写了一个查询来检查符合特定条件的用户,其中一个是他们有电子邮件地址.

                  I've wrote a query to check for users with certain criteria, one being they have an email address.

                  我们的网站将允许用户拥有或不拥有电子邮件地址.

                  Our site will allow a user to have or not have an email address.

                  $aUsers=$this->readToArray('
                   SELECT `userID` 
                   FROM `users` 
                   WHERE `userID` 
                   IN(SELECT `userID`
                           FROM `users_indvSettings`
                    WHERE `indvSettingID`=5 AND `optionID`='.$time.')
                    AND `email`!=""
                   ');
                  

                  这是在 SQL 中检查空字段的最佳方法吗?我刚刚尝试了IS NOT NULL",这仍然返回了一个用户记录,而他们没有电子邮件地址.

                  Is this the best way to check for an empty field in SQL? I've just tried "IS NOT NULL" and this still returned a users record without them having an email address.

                  上面的查询有效,但出于好奇,我想知道我是否以正确的方式进行操作.

                  The query above works but out of curiosity I wondered if I'm doing it the correct way.

                  推荐答案

                  空字段可以是空字符串或 NULL.

                  An empty field can be either an empty string or a NULL.

                  要同时处理这两种情况,请使用:

                  To handle both, use:

                  email > ''
                  

                  如果您的表格中有大量空电子邮件记录(两种类型),则可以从 range 访问中受益.

                  which can benefit from the range access if you have lots of empty email record (both types) in your table.

                  这篇关于使用 MySQL 检查空字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP 认为 null 等于零 下一篇:如何在 yii2 中使用事件?

                  相关文章

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

                3. <tfoot id='EYPM6'></tfoot>
                    <bdo id='EYPM6'></bdo><ul id='EYPM6'></ul>

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