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


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.

Updated on: 22-Jun-2020

69 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements