问题描述:
查询所有的数据,查询结果:146360
select
count(1) from bank_cde;
in查询的获取部分数据,查询结果 :73080
select
count(1) from bank_cde t where t.belongcode2 in(‘ABC‘,‘BCOM‘,‘BOC‘,‘CCB‘,‘CEB‘,‘CGB‘,‘CIB‘,‘CITIC‘,‘CMBC‘,‘ICBC‘,‘PAB‘,‘POST‘,‘SPDB‘);
not in查询数据,结果为0
select
count(1) from bank_cde t where t.belongcode2 not in(‘ABC‘,‘BCOM‘,‘BOC‘,‘CCB‘,‘CEB‘,‘CGB‘,‘CIB‘,‘CITIC‘,‘CMBC‘,‘ICBC‘,‘PAB‘,‘POST‘,‘SPDB‘);
原因:
本以为in 和not in 为查询两种结果互补,还有一种情况 为 null
select
count(1) from bank_cde t where t.belongcode2 isnull;
原文:http://www.cnblogs.com/choiyubo163com/p/7561583.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!