MySQL列名称和别名 [英] MySQL column names and aliases
问题描述
我已经阅读到选择后我们使用列名,但是我发现了一条类似这样的语句:
I have read that after select we use column-names but I have found a statement that was like this:
SELECT 'A' FROM T WHERE A = NULL;
你愿意帮我吗?谢谢(这里是列名吗?) 我的DBMS是MySQL
would you lease help me? thanks (A is a column- name here?) my DBMS is MySQL
确切的问题是这样的: 上面的语句是否会产生一行(选择所有 申请)?请注意,ANSI_NULLS为OFF.
EDITED : the exact question is this that: Will the above statement produce a row (select all that apply)? Notice that ANSI_NULLS is OFF.
我想知道上面的陈述会奏效吗?因为有些人说我们应该写IS NULL而不是= null
I want to know that the above statement will work? because some of you said that we should write IS NULL instead of =null
推荐答案
基于该查询,对于名为A的列等于null的每一行,您将获得一个包含字符'A'的结果集.
Based on that query, you would get a result set containing the character 'A' for each row where the column named A was equal to null.
如果您实际上想查看A列的值而不是字符"A",则必须删除单引号:
If you actually want to see the value of the column A instead of the character 'A', you have to remove the single quotes:
SELECT A FROM T WHERE A IS NULL
无论哪种方式,都不应该使用= NULL
.某些RDMS无法按照您的想法进行处理.标准是使用IS NULL
代替.
Either way, you should not use = NULL
. Certain RDMSs don't handle that the way you would think. The standard is to use IS NULL
instead.
这篇关于MySQL列名称和别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!