IFNULL( )

Original link: http://blog.csdn.net/u013031565/article/details/52080962

IFNULL(expr1,expr2) Usage
If expr1 is not NULL, the return value of IFNULL() is expr1; otherwise, the 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. The default result value of IFNULL(expr1, expr2) is the more "generic" of the two expressions, in the order STRING, REAL, or INTEGER.

mysql> SELECT IFNULL(1,0);
-> 1
mysql> SELECT IFNULL(NULL,10);
-> 10
mysql> SELECT IFNULL(1/0,10);
-> 10
mysql> SELECT IFNULL(1/0,'yes');
-> 'yes'

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325440875&siteId=291194637