問題描述:
查詢所有的數據,查詢結果: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 is null;
