Preamble

In this article, you will learn how to display NULL values in other meaningful values.
Dr.EFCodd, who is the creator of the relational model for the database, introduced this concept of NULL in the theory of relational databases.
According to Dr.EFCodd, NULL means unknown value or missing information.
MySQL also supports NULL, which represents the concept of missing or inapplicable information.
In the database table, you store data that contain NULL values
When you provide data to users in the form of reports, it makes no sense to show NULL values.
To make reports more readable and understandable, you need to display NULL values in the form of other values, such as unknown, missing, or inaccessible (no data). You can do this by using the IF function.
The syntax of the IF function is as follows:
IF(exp,exp_result1,exp_result2);
If the value of exp is TRUE (when exp <> 0 and exp <> NULL), then IF returns a value from otherwise exp_result1 returns exp_result2.
The IF return can be a string or a number, depending on exp_result1 and exp_result2.
Lets practice with some examples for a better understanding
Below is the partial data in the customer table, which includes the customername state and country:
SELECT
customername, state, country
FROM
ORDER BY country;
Status values are not available for some clients. You can use the IF function to display the NULL value as N/A:
SELECT
customername, IF(state IS NULL, 'N/A', state) state, country
FROM
ORDER BY country;
In addition to the IF function, MySQL provides the IFNULL function, which allows NULL to process values directly. The syntax of the IFNULL function is given below:
IFNULL(exp,exp_result);
The IFNULL function returns the value of the expression exp_result if exp is calculated as NULL, otherwise, it returns the value of exp.
In the next query, the IFNULL function displays NULL as unknown as follows:
SELECT customername,
IFNULL(state, "N/A")state,
country
FROM customers
ORDER BY country;
In this article, you learned how to use IF and IFNULL to display NULL values on other more important values to present data in a readable form.
Important concepts on NULL values
Enteros
About Enteros
IT organizations routinely spend days and weeks troubleshooting production database performance issues across multitudes of critical business systems. Fast and reliable resolution of database performance problems by Enteros enables businesses to generate and save millions of direct revenue, minimize waste of employees’ productivity, reduce the number of licenses, servers, and cloud resources and maximize the productivity of the application, database, and IT operations teams.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
Revolutionizing SaaS Database Performance with AI SQL and AIOps Observability—Powered by Enteros
- 16 September 2025
- Database Performance Management
Introduction The Software-as-a-Service (SaaS) industry is the backbone of modern digital transformation. From enterprise collaboration platforms to CRM solutions, SaaS products are deeply embedded in daily business operations. At the heart of every SaaS application lies its database, where speed, scalability, and resilience directly shape customer experience and business success. Yet, as SaaS platforms scale, … Continue reading “Revolutionizing SaaS Database Performance with AI SQL and AIOps Observability—Powered by Enteros”
Balancing the Insurance Sector’s Digital Balance Sheet: How Enteros Uses AIOps and Cloud FinOps to Drive RevOps Efficiency
Introduction The insurance sector stands at a crossroads of tradition and digital transformation. Once reliant on paper records, manual claims processing, and legacy IT systems, insurers today operate in a hyper-connected ecosystem of digital policies, AI-driven underwriting, fraud detection, and customer self-service portals. At the heart of this transformation lies data—massive, complex, and constantly growing. … Continue reading “Balancing the Insurance Sector’s Digital Balance Sheet: How Enteros Uses AIOps and Cloud FinOps to Drive RevOps Efficiency”
Microfinance platforms scaling to millions
- 15 September 2025
- Software Engineering
Introduction Microfinance has transformed financial inclusion, giving underserved communities access to credit and opportunity. But as platforms scale from thousands to millions of borrowers, the very systems enabling this mission can become bottlenecks. The Challenge Peak-hour overload: thousands apply at once, slowing approvals. Read moreMongoDB profiler and database performance problem diagnosis and identificationDelays in scoring: … Continue reading “Microfinance platforms scaling to millions”
Breaking news under load
When traffic spikes become breaking points Election nights. Natural disasters. Global events. In those moments, audiences turn to news sites in record numbers. But just when the newsroom needs to move fastest, the CMS and databases often slow to a crawl. The result: missed updates, frustrated readers, and credibility at risk. When breaking news slows, … Continue reading “Breaking news under load”