oracle sql like(模糊查询)时,null的处理

      oracle中,模糊查询使用like和 not like 。 

      item表中,log字段为备注,备注中存在“抽检”两个字的时候,不统计该项目。备注可以为null。

select * from item where log not like "%抽检%";

      期望的情况是:除了抽检的单子,其他单子都筛选出来。 实际情况是:只有 备注不为null且备注不包含“抽检”连个工资的才被筛选出来。

      后来发现,oracle中,使用nvl()进行处理即可。

select * from item where nvl(log,0) not like '抽检'

      详情可参考: https://blog.csdn.net/haiross/article/details/43272125

发布了48 篇原创文章 · 获赞 36 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/weixin_42845682/article/details/88814383
今日推荐