mysql中null是不參與計算的,對null進行計算,使用 is null 和 is not null 運算子結論:如果在只有 「<=>」 才支援null的比較,其他比較運算對有null運算元時返回的結果就是null,永遠返回false,即 null = null 返回false
not in
子查詢中有null
值的時候則不會返回資料,即查詢結果為空,所有的運算結果都是false,所以要避免not in的list**現null的情況
mysql> select 1 not in (1,2,3);
+------------------+
| 1 not in (1,2,3) |
+------------------+
| 0 |
+------------------+
1 row in set (0.00 sec)
mysql> select 1 not in (1,2,3,null);
+-----------------------+
| 1 not in (1,2,3,null) |
+-----------------------+
| 0 |
+-----------------------+
1 row in set (0.00 sec
mysql> select 1 not in (2,3);
+----------------+
| 1 not in (2,3) |
+----------------+
| 1 |
+----------------+
1 row in set (0.00 sec)
mysql> select 1 not in (2,3,null);
+---------------------+
| 1 not in (2,3,null) |
+---------------------+
| null |
+---------------------+
1 row in set (0.00 sec)
Mysql的NULL值問題
null值在資料庫中表示未知值或者不存在,null與任何資料進行操作的結果都是null。1.null與數值型別進行算術運算結果為null。2.null與數值型別進行關係運算結果為null。3.null與字串型別進行操作的結果為null。4.判斷乙個值是否為null要使用is null或者is not...
MySQL中null值問題
今天寫答疑系統的時候,寫了這樣一截 session start db mysqli connect localhost root root qa tname post teacher q select schedule,place from time where tname tname and sn...
mysql之null值處理函式
ifnull expr1,expr2 如果第乙個引數 expr1 不為null則直接返回它,否則返回第二個引數 expr2。返回值是數字或者字串。它相當於oracle中的nvl函式 select ifnull 1,0 select ifnull null,10 select ifnull 1 0,y...