Home  >  Article  >  Database  >  What is the use of the MySQL NULLIF() control flow function?

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

PHPz
PHPzforward
2023-09-12 12:13:021185browse

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

The MySQL NULLIF() control flow function will return NULL if the two parameters are the same, otherwise it will return the first parameter.

Syntax

NULLIF(expression1, expression2)

Here, if expression1 = expression2, NULLIF() will return NULL, otherwise it will return expression1. The following example will demonstrate this -

mysql> Select NULLIF('Ram','Ram');
+---------------------+
| NULLIF('Ram','Ram') |
+---------------------+
| NULL                |
+---------------------+
1 row in set (0.00 sec)

mysql> Select NULLIF('Ram','Shyam');
+-----------------------+
| NULLIF('Ram','Shyam') |
+-----------------------+
| Ram                   |
+-----------------------+
1 row in set (0.00 sec)

The above is the detailed content of What is the use of the MySQL NULLIF() control flow function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete