<legend id='33Uj3'><style id='33Uj3'><dir id='33Uj3'><q id='33Uj3'></q></dir></style></legend>
  1. <tfoot id='33Uj3'></tfoot>

    • <bdo id='33Uj3'></bdo><ul id='33Uj3'></ul>

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

    2. MySQL 错误:“where 子句"中的未知列

      时间:2023-10-26
        <bdo id='XPKTS'></bdo><ul id='XPKTS'></ul>
      • <small id='XPKTS'></small><noframes id='XPKTS'>

          <tbody id='XPKTS'></tbody>
            <tfoot id='XPKTS'></tfoot>
              <i id='XPKTS'><tr id='XPKTS'><dt id='XPKTS'><q id='XPKTS'><span id='XPKTS'><b id='XPKTS'><form id='XPKTS'><ins id='XPKTS'></ins><ul id='XPKTS'></ul><sub id='XPKTS'></sub></form><legend id='XPKTS'></legend><bdo id='XPKTS'><pre id='XPKTS'><center id='XPKTS'></center></pre></bdo></b><th id='XPKTS'></th></span></q></dt></tr></i><div id='XPKTS'><tfoot id='XPKTS'></tfoot><dl id='XPKTS'><fieldset id='XPKTS'></fieldset></dl></div>
              • <legend id='XPKTS'><style id='XPKTS'><dir id='XPKTS'><q id='XPKTS'></q></dir></style></legend>
              • 本文介绍了MySQL 错误:“where 子句"中的未知列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个名为 bank 的表,其中包含三列:uidnickbalance.

                I have a table called bank with three columns: uid, nick, balance.

                我正在尝试创建一个查询,该查询将根据昵称返回余额,但在使用此查询时出现错误 Unknown column 'Alex' in 'where clause':

                I am trying to create a query that will return the balance based on the nick, and I am getting an error Unknown column 'Alex' in 'where clause' when I use this query:

                SELECT b.balance FROM bank AS b WHERE b.nick=`Alex` LIMIT 1
                

                谁能看到我在这里做错了什么?

                Can anyone see what I am doing wrong here?

                推荐答案

                反引号 (`) 用于标识符,如表名、列名等.单引号 (') 用于字符串文字.

                backticks (`) are used for identifiers, like table names, column names, etc. Single quotes(') are used for string literals.

                你想做:

                SELECT b.balance FROM bank AS b WHERE b.nick='Alex' LIMIT 1
                

                或者,更明确地说:

                SELECT `b`.`balance` FROM `bank` AS b WHERE `b`.`nick`='Alex' LIMIT 1
                

                如果没有歧义,并且表/列名称没有特殊字符或空格,则可以将 ` 关闭.

                When there is no chance of ambiguity, and when table/column names do not have special characters or spaces, then you can leave the ` off.

                以下是一些枯燥且难以阅读的文档:http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

                Here is some documentation that is dry and hard to read: http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

                但这里有一个关于 dba.stackoverflow 的相关问题,它更容易阅读:https://dba.stackexchange.com/questions/23129/benefits-of-using-backtick-in-mysql-queries

                But here is a related question on dba.stackoverflow that is easier to read: https://dba.stackexchange.com/questions/23129/benefits-of-using-backtick-in-mysql-queries

                这是一个非常好的页面,我推荐大家阅读:http://www.sitepoint.com/forums/showthread.php?408497-the-big-bad-thread-of-quot-MySQL-Best-Practices-and-Other-Useful-Information-quot

                And here is a very good page that I recommend everyone read: http://www.sitepoint.com/forums/showthread.php?408497-the-big-bad-thread-of-quot-MySQL-Best-Practices-and-Other-Useful-Information-quot

                这篇关于MySQL 错误:“where 子句"中的未知列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:选择没有重复条目的一行 下一篇:MySQL是否“选择限制1"?有多条记录从顶部选择第一条记录?

                相关文章

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

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

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