RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL
Expertise: Intermediate
Dec 7, 2017

Understanding Null Values Returned in MySQL

The null value often needs special attention in your code to work effectively.

For developers, it is important to know if the value that was received for a query is null or not. However, different programming languages handle the return of null values differently. With MySQL, it becomes easier as you can tell what to return in case of null and not null. This makes your programming logic easier, better and more effective.

SELECT ISNULL(column_name) FROM `database_name`.`table_name`;

Here, ISNULL will populate the column value with 0 if the value is null and with 1 if the value is not null. Based on this, we can handle null cases effectively in our code.

M S Sridhar
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date