How does MySQL evaluate the expression if the arguments are not equal in NULLIF()?

MySQLMySQLi Database

As we know that MySQL NULLIF() control flow function will return the first argument both the arguments are not the same. The first argument is returned because MySQL evaluates the first argument twice if both of the arguments are not the same.

Example

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

In the above example, as the arguments are not the same hence MySQL evaluates the first argument i.e.’Tutorialspoint’ two times and return it as output.

raja
Published on 21-Feb-2018 10:59:26
Advertisements