空字符串与NULL(Empty string vs NULL)
我有一张表,其中一些行有一些空白cells 。 我试图使用IS NULL函数选择这样的行。 但查询选择0行。
select * from zzz_fkp_registration_female where fname is null; (0 row(s) affected)现在我将查询更改为:
select * from zzz_fkp_registration_female where fname is null or fname ='';我得到了理想的结果。
为什么IS NULL没有给出结果? IS NULL和''之间有什么区别,因为单元格是空的。 请解释。
I've a table where some rows have some blank cells. I tried to select such rows using IS NULL function. But the query select 0 rows.
select * from zzz_fkp_registration_female where fname is null; (0 row(s) affected)Now I changed my query to:
select * from zzz_fkp_registration_female where fname is null or fname ='';I got the desired result.
Why is IS NULL not giving the result? What is the difference between IS NULL and '' since the cells are empty. Please explain.
最满意答案
他们之间的一些差异:
NULL可以分配给任何类型,而不是与日期/数字字段不兼容的空字符串。 NULL是一个UNKNOWN值,它没有值而不是空字符串,这是一个值,但是为空值。 据我所知, NULL不应该捕获内存而不是空字符串。 null = null将导致null而不是''=''将导致TRUE 。Some differences between them:
NULL can be assigned to any type, as opposed to empty string which won't be compatible with date/numerical fields. NULL is an UNKNOWN value, it doesn't have a value as opposed to an empty string, which is a value, but empty one. As far as I'm aware of, NULL shouldn't capture memory as opposed to an empty string which does. null = null will result in null as opposed to ''='' which will result in TRUE.更多推荐
发布评论