mysql 查询某个字段为空或不为空的数据

mysql 查询某个字段为空或不为空的数据,第1张

查询字段为空的数据。如下三条语句查询的结果各不相同。

select count(0) from tps_uw_detail where trim(coreContNo)=''###1736

select count(0) from  tps_uw_detail where coreContNo is null###735

select count(0) from  tps_uw_detail where (coreContNo is null or trim(coreContNo)='')##2471

=''就是存的空字符串;is null 就是默认的。

由于是后来新加的字段,默认为null,所以历史数据都为null。表中加上这个字段后,再落库的数据就是空字符串了。

根据自己的需求选用脚本,第三个是适合我的。

mysql中查询字段为null或者不为null

在mysql中,查询某字段为空时,切记不可用 = null,

而是 is null,不为空则是 is not null

www.2cto.com

select * from table where column is null

select * from table where column is not null


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7481240.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-06
下一篇2023-04-06

发表评论

登录后才能评论

评论列表(0条)

    保存