[MySQL function] MYSQLIFNULL and IF functions use bitsCN.com
[MySQL function] Use of mysql ifnull and IF functions
The usage of the mysql ifnull function is described in detail below for your reference. if you have encountered similar problems in using the mysql ifnull function, take a look.
MYSQL IFNULL(expr1,expr2)
If expr1 is not null, IFNULL () returns expr1; otherwise, it returns expr2. IFNULL () returns a number or string value, depending on the context in which it is used.
mysql> select IFNULL(1,0); -> 1 mysql> select IFNULL(0,10); -> 0 mysql> select IFNULL(1/0,10); -> 10 mysql> select IFNULL(1/0,'yes'); -> 'yes '
IF (expr1, expr2, expr3)
IF expr1 is TRUE (expr1 <> 0 and expr1 <> NULL), IF () returns expr2; otherwise, expr3 is returned. IF () returns a number or string value, depending on the context in which it is used.
mysql> select IF(1>2,2,3); -> 3 mysql> select IF(1<2,'yes','no'); -> yes mysql> select IF(strcmp('test','test1'),'yes','no'); //strcmp('test','test1')=-1 -> yes
BitsCN.com