IFNULL(expr1,expr2) : IFNULL : Control Flow Functions MySQL TUTORIALS


MySQL TUTORIALS » Control Flow Functions » IFNULL »

 

IFNULL(expr1,expr2)


If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.

mysql>
mysql> SELECT IFNULL(1,0);
+-------------+
| IFNULL(1,0|
+-------------+
|           |
+-------------+
row in set (0.00 sec)

mysql>
mysql> SELECT IFNULL(NULL,10);
+-----------------+
| IFNULL(NULL,10|
+-----------------+
|              10 |
+-----------------+
row in set (0.00 sec)

mysql>
mysql> SELECT IFNULL(1/0,10);
+----------------+
| IFNULL(1/0,10|
+----------------+
|        10.0000 |
+----------------+
row in set (0.00 sec)

mysql>
mysql> SELECT IFNULL(1/0,'yes');
+-------------------+
| IFNULL(1/0,'yes') |
+-------------------+
| yes               |
+-------------------+
row in set (0.00 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Control Flow Functions
» IFNULL