MySQL如何进行非空查询


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!=”
MySQL
Nginx
  • 作者:remember(联系作者)
  • 发表时间:2021-07-02 16:48
  • 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)
  • 公众号转载:请在文末添加作者公众号二维码
  • 评论