Computer >> Computer tutorials >  >> Programming >> MySQL

What would be the output if we use a NULL value in an arithmetic expression?


As we know that a NULL is no value and it is not the same as zero. MySQL represents a database column as NULL if it does not contain any data. Now, if we will use NULL in any arithmetic expression then the result will be NULL also.

Example

mysql> Select 65/NULL,65+NULL,65*NULL,65-NULL,65%NULL;
+---------+---------+---------+---------+---------+
| 65/NULL | 65+NULL | 65*NULL | 65-NULL | 65%NULL |
+---------+---------+---------+---------+---------+
|    NULL |    NULL |    NULL |    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.