Source: http://blog.csdn.net/a466350665/article/details/52994761
http://blog.csdn.net/xingyu0806/article/details/52080962
ifnull (EXPR1,EXPR2) usage: if EXPR1 is not NULL, the return value of Ifnull () is expr1; Otherwise its return value is EXPR2. The return value of Ifnull () is either a number or a string, depending on the context in which it is used.
mysql> SELECT ifnull (1,0);
& nbsp 1
mysql> SELECT ifnull (null,10);  &NBSP
&N Bsp  &NBSP
mysql> SELECT ifnull (1/0,10);
&nbs P
mysql> SELECT ifnull (1/0, ' yes ');  &NBSP
&N Bsp ' Yes ' the default result value for
ifnull (EXPR1,EXPR2) is one of the more "common" in two expressions, in the order of string, real, or INTEGER.
ISNULL (expr) usage: If expr is null, then the return value of ISNULL () is 1, otherwise the return value is 0.
mysql> Select IsNull (+);
0
Mysql> Select IsNull (1/0);
1
The comparison of NULL values using = is usually wrong.
nullif (EXPR1,EXPR2) Usage: If EXPR1 = EXPR2 is established, then the return value is NULL, otherwise the return value is EXPR1. This is the same as when the case is Expr1 = Expr2 then NULL ELSE expr1 end.
Mysql> SELECT Nullif ();
, NULL
Mysql> SELECT Nullif;
1
If the arguments are not equal, the MySQL two-time value is expr1.
Ifnull, ISNULL, Nullif usage in MYSQL (database empty)