Understanding NULL in MySQL

Understanding NULL in MySQL

NULL is a unique value. It represents a value that is not defined and that is not really equal to BLANK (”).

While using it in queries, we need to use the utmost care.

Here are a few examples in which you might be confused with the output unless you are very comfortable using NULL.

1. When NULL is added to a number, the output is still NULL

Query: SELECT 1 + NULL;


+-----------+| 1 + NULL  |+-----------+| (NULL)    |+-----------+

2. When used with a string function such as CONCAT

Query: SELECT CONCAT(‘Indigo’,NULL);


+------------------------+| CONCAT('Indigo',NULL)  |+------------------------+| (NULL)                 |+------------------------+

Alternatively, when the query is SELECT CONCAT(‘Indigo’,’ Nation’);


+-----------------------------+| CONCAT('Indigo',' Nation')  |+-----------------------------+| Indigo Nation               |+-----------------------------+

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist