emp表中的數據
1. 使用in的時候,忽略為null的,不會查詢出comm為null的數據
select * from emp e where e.comm in (300, 500, null);
2. 使用not in的時候,如果 not in后面的選項中沒有null,只會查詢從comm列不為空的列中過濾,會過濾掉comm為null的數據
select * from emp e where e.comm not in (300, 500);
3. 使用not in 的時候,如果not in后面的選項中有null,不會查詢出來任何數據。sql語句本身直接返回false,所以使用not in的時候,要保證in中的條件不會出現null的情況,不然可能會出現意想不到的情況。
select * from emp e where e.comm not in (300, 500, null);