Home > Database > Mysql Tutorial > What is the use of the MySQL IFNULL() control flow function?

What is the use of the MySQL IFNULL() control flow function?

王林
Release: 2023-09-11 17:25:02
forward
625 people have browsed it

MySQL IFNULL()控制流函数有什么用?

MySQL IFNULL() control flow function returns the first argument if it is not NULL, otherwise returns the second argument.

Syntax

IFNULL(expression1, expression2)
Copy after login

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)
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template