今天在一个项目中使用一条查询语句时发现了一个sql语句出问题了,语句如下
select * from collect_device m where 1=1 and m.id not in(select f.collect_id from snmp_device f)
之后我发现在select f.collect_id from snmp_device f这个sql语句中有一条数据为null。哦~~原来in语句中的数据有一条为null值的话,整个sql语句都会查不到数据的,之后我又改为
select * from collect_device m where 1=1 and m.id not in(select f.collect_id from snmp_device f where f.collect_id is not null)
问题就解决了
数据库问题小记
猜你喜欢
转载自fcdxdx.iteye.com/blog/1757037
今日推荐
周排行