今天发现了一个sql的小问题

这里有三条sql语句,想找到存在tblA中,却又不在tblB中的记录数

select count*from tblA
select count(*from tblA where pid in ( select pid from
 tblB)
select count(*from tblA where pid not in  select pid from tblB)
结果运行的结果是
1070
按理应该是 10,7,3 才对阿,
后来才发现最后一句应该这样写
select count(*from tblA where pid not in (select pid from tblB where pid is not null)

运行后的结果才对:10,7,3
只是不知道为什么最后一句不取掉空项就select 不出来

posted @ 2004-07-06 13:19  bluehat  阅读(885)  评论(1编辑  收藏  举报