IFNULL in MySQL Last Updated : 03 Mar, 2018 Comments Improve Suggest changes 14 Likes Like Report Given a TABLE, in this TABLE, it prints entry of the table. If table is empty then it gives NULL. Examples: QUESTION : Given an employee table, print name from the given table which id equals to 2. Output : Geek2 QUESTION : Given same Employee table, print name from the given table which id equals to 5. Output : NULL Approach: In this case, we use here IFNULL. IFNULL print the null if the table is an empty or other condition. Query:- SELECT IFNULL( (SELECT NAME from employee where id = 2), 'NULL') as NAME; Output:- Geek2 Query:- SELECT IFNULL( (SELECT NAME from employee where id = 5), 'NULL') as NAME; Output:- NULL Comment D devanshuagarwal Follow 14 Improve D devanshuagarwal Follow 14 Improve Article Tags : Misc SQL mysql Explore SQL Tutorial 6 min read BasicsWhat is SQL? 6 min read SQL Data Types 3 min read SQL Operators 4 min read SQL Commands | DDL, DQL, DML, DCL and TCL Commands 4 min read SQL Database Operations 3 min read SQL CREATE TABLE 3 min read Queries & OperationsSQL SELECT Query 2 min read SQL INSERT INTO Statement 4 min read SQL UPDATE Statement 3 min read SQL DELETE Statement 3 min read SQL - WHERE Clause 3 min read SQL | Aliases 3 min read SQL Joins & FunctionsSQL Joins (Inner, Left, Right and Full Join) 4 min read SQL CROSS JOIN 2 min read SQL | Date Functions 4 min read SQL | String functions 6 min read Data Constraints & Aggregate FunctionsSQL NOT NULL Constraint 2 min read SQL PRIMARY KEY Constraint 5 min read SQL Count() Function 7 min read SQL SUM() Function 5 min read SQL MAX() Function 4 min read AVG() Function in SQL 4 min read Advanced SQL TopicsSQL Subquery 4 min read Window Functions in SQL 6 min read SQL Stored Procedures 7 min read SQL Triggers 5 min read SQL Performance Tuning 6 min read SQL TRANSACTIONS 6 min read Database Design & SecurityIntroduction of ER Model 10 min read Introduction to Database Normalization 6 min read SQL Injection 11 min read SQL Data Encryption 5 min read SQL Backup 4 min read What is Object-Relational Mapping (ORM) in DBMS? 7 min read Like