in和=无法查出为NULL的值

select * from base.persons x where x.pname in ( null)
select * from base.persons x where x.pname = ( null)
--以上两句查询结果为空。虽然表里有相应的值。

 Id=NULL 为UNKNOWN。 那么无法查询出列值为Null的记录。

另外:x.id != null结果也为空。

解决方法:

在in 和not in的操作之前先把NULL 过滤掉(可通过IS NULL)

猜你喜欢

转载自cwj158.iteye.com/blog/1416777