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


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.

Updated on: 22-Jun-2020

64 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements