您的位置:首页技术文章
文章详情页

mysql - msyql 判断字段不为空 简单方法

【字号: 日期:2022-06-16 18:33:35浏览:46作者:猪猪

问题描述

一般判断是否空where name is not null and name != ’’;

有没有简单方法 一步到位

length(name)>0 是个方法;有没有empty等?

问题解答

回答1:

name != null;是错误的,因为null都不等于null

mysql> select null=null;null=nullNULL

1 row in set (0.03 sec)

mysql> select null is null;null is null1

1 row in set (0.00 sec)

判断不为空,如果字段default null where name is not null 否则 where name != ’’

相关文章: