首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

not in带来的有关问题

2012-07-18 
not in带来的问题在使用not in 的时候,内表和外表比较的字段如果含有null的话会出现查询逻辑错误的问题,如

not in带来的问题
在使用not in 的时候,内表和外表比较的字段如果含有null的话会出现查询逻辑错误的问题,如:
select count(1) from "customer_tmp"  t where t."name" not  in (select "name" from "client1")

如果name的值为null的话,用not in会有逻辑错误!

结论:还是全部换成not exists吧,语法如下:
select count(1) from "customer_tmp" t where  not exists (select c."name" from "client1" c where c."name"=t."name")

热点排行