空字符串vs NULL [英] Empty string vs NULL

查看:108
本文介绍了空字符串vs NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子,其中一些行的空白单元格。我试图使用IS NULL函数选择此类行。但是查询选择0行。

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)

现在我将查询更改为:

select * from zzz_fkp_registration_female where fname is null or fname ='';

我得到了想要的结果。

I got the desired result.

为什么NULL不给出结果?由于单元格为空, IS NULL '’有什么区别?请解释。

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 是一个未知值,它没有值,而不是一个空字符串,它是一个值,但为空。

  • 据我所知, NULL 不应捕获内存,而不是捕获空字符串。

  • null = null 将导致 null 而不是''= 会导致 TRUE

  • 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.

这篇关于空字符串vs NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆