When a MySQL arithmetic expression returns NULL?

MySQLMySQLi Database

As we know that a NULL is not a value and it is also not the same as zero. MySQL arithmetic expression returns NULL if we will use NULL in it. It can be understood with the help of the following example −

Example

mysql> Select 100*NULL;
+----------+
| 100*NULL |
+----------+
|     NULL |
+----------+
1 row in set (0.00 sec)

mysql> Select 100+NULL;
+----------+
| 100+NULL |
+----------+
|     NULL |
+----------+
1 row in set (0.00 sec)

From the above example, it can be observed that if we will use NULL in an arithmetic expression then the result would be NULL itself.

raja
Published on 22-Feb-2018 07:50:00
Advertisements