null與in:null值不會包含在in的結果集中。
A105024@O02DMS1>select * from test;
ID NAME
---------- -------------- ------
1 A
B
3 C
A105024@O02DMS1>select * from test where id in (1);
ID NAME
---------- --------------------
1 A
A105024@O02DMS1>select * from test where id not in(1);
ID NAME
---------- --------------------
3 C
從上面的例子我們可以看出,不管是in還是not in,null值都不 在結果集中,除非顯示的聲明:
A105024@O02DMS1>select * from test where id is null;
ID NAME
---------- ------------------- -
B
-->null與“加減乘除等於”的關 系:null不能用來進行等於比較;與任何東西的加減乘除的結果都是null。
A105024@O02DMS1>select * from test where id = null;
no rows selected
A105024@O02DMS1>select id+1 from test where id is null;
ID+1
----------
null與集合運算的關係:集合運算中將所 有的null作為相等的值來對待。
A105024@O02DMS1>select null from dual union select null from dual;
N
-
A105024@O02DMS1>select null from dual minus select null from dual;
no rows selected
-->null與Group by 的 關係:group by把null作為一個值來對待。
A105024@O02DMS1>select id,count(*) from test group by id;
ID COUNT(*)
-- -------- ----------
1 1
1
3 1