Jump to: navigation, search

Mysql NULLIF

From w3cyberlearnings

Contents

MySQL NULLIF Function

This operator uses to check two expression.

Syntax NULLIF

When expr1=expr2 returns NULL, otherwise returns expr1.

NULLIF(expr1,expr2)

Example 1

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

Example 2

mysql> SELECT NULLIF(2,3),NULLIF(5,5),NULLIF('good','bad');
+-------------+-------------+----------------------+
| NULLIF(2,3) | NULLIF(5,5) | NULLIF('good','bad') |
+-------------+-------------+----------------------+
|           2 |        NULL | good                 | 
+-------------+-------------+----------------------+
1 row in set (0.00 sec)


Related Links


--CASE-- IF-- IFNULL-- NULLIF--

Navigation
Web
SQL
MISC
References