What would be the result if we perform any kind of arithmetic calculations in MySQL having one of the arguments as NULL?

MySQLMySQLi Database

MySQL always throws NULL as the result of arithmetic calculations in which one of the arguments is NULL. Consider the following example having NULL as an argument with addition, subtraction, multiplication, and division −

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

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

mysql> Select 10-NULL;
+---------+
| 10-NULL |
+---------+
|    NULL |
+---------+
1 row in set (0.07 sec)

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

The output of all the arithmetic calculations above is NULL because of NULL as one of the arguments in it.

raja
Published on 22-Feb-2018 06:25:07
Advertisements