mysql 查空对象和非空对象

1、查询字段DesOrgCode为(NULL) 记录
SELECT * from crossalarm where DesOrgCode is null ;
//不为(NULL)
SELECT * from crossalarm where DesOrgCode is not null ;

2、查询字段DesOrgCode为 '' 记录
SELECT * from crossalarm where DesOrgCode = '' ;
//不为 ''
SELECT * from crossalarm where DesOrgCode <> '' ;

3、查询字段DesOrgCode为 '' 和 (NULL) 的记录
SELECT * from crossalarm where IFNULL(DesOrgCode,'') = ''
//不为 '' 和 (NULL)
SELECT * from crossalarm where IFNULL(DesOrgCode,'') <> ''

 

posted @ 2020-04-25 14:10  剑存古风  阅读(552)  评论(0)    收藏  举报