oracle使用不等於(<>)條件過濾數據時會把NULL給過濾掉
解決方案1:select * from sample where a <> 'A' or a is null;
解決方案2:select * from sample where nvl(a,'default') <> 'A';
mysql在使用不等於(<>)條件過濾數據時也會把NULL給過濾掉
解決方案1:select * from sample where a <> 'A' or a is null;
解決方案2:select * from sample where ifnull(a,'default') <> 'A';
注意:
mysql中的NULL與空字符串('')是不相等的,是兩個不同的值
NULL使用is null 或者 is not null判斷
空字符串('')使用=''或者<>''進行判斷
使用不等於時需要注意會過濾NULL值
count()統計時會忽略掉NULL值,不在統計之中,使用時需要注意
Oracle的NULL等價於空字符串('')
插入空字符串('')會被默認替換成NULL