1、空值与空字符串不同,判断方法也不同
- 判断NULL用is null 或者 is not null。
- 判断空字符串,要用 =”或者 <>”。
2、用法说明
-
获取空值或非空值的数据:
- 获取字段field为空值的数据,语法:【select * from tableName where field is null】
- 获取字段field为非空值的数据,语法:【select * from tableName where field is not null】
-
获取空字符串或非空字符串的数据:
- 获取字段field为空字符串的数据,语法:【select * from tableName where field=”】
- 获取字段field为非空字符串的数据,语法:【select * from tableName where
field!=”】
本文介绍了数据库中空值(NULL)与空字符串的区别,并提供了SQL查询语句来筛选空值和空字符串的数据。空值用`isnull`或`isnotnull`判断,而空字符串则通过`=`或`<>`比较。了解这些差异对于有效地处理数据至关重要。
1532

被折叠的 条评论
为什么被折叠?



