空字符串与NULL(Empty string vs NULL)

系统教程 行业动态 更新时间:2024-06-14 16:57:18
空字符串与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.

更多推荐

本文发布于:2023-04-12 20:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/7cfa035aa9c5ac0008f8bae918a10ef0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空字符串   NULL   string   Empty

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!