Home >Database >Mysql Tutorial >What is the use of the MySQL IFNULL() control flow function?
MySQL IFNULL() control flow function returns the first argument if it is not NULL, otherwise returns the second argument.
IFNULL(expression1, expression2)
Here if expression 1 is not NULL, IFNULL() will return expression 1, otherwise it will return expression 2. If both parameters are NULL, it returns NULL. The following example will demonstrate this -
mysql> Select IFNULL(NULL,'Ram'); +--------------------+ | IFNULL(NULL,'Ram') | +--------------------+ | Ram | +--------------------+ 1 row in set (0.00 sec) mysql> Select IFNULL('Shyam','Ram'); +-----------------------+ | IFNULL('Shyam','Ram') | +-----------------------+ | Shyam | +-----------------------+ 1 row in set (0.00 sec) mysql> Select IFNULL(NULL,NULL); +-------------------+ | IFNULL(NULL,NULL) | +-------------------+ | NULL | +-------------------+ 1 row in set (0.00 sec)
The above is the detailed content of What is the use of the MySQL IFNULL() control flow function?. For more information, please follow other related articles on the PHP Chinese website!