IFNULL returns the specified value if the expression returns null in a table. Else returns the expression.
Example:
SELECT IFNULL(NULL, "I Am Back")
We are going to use the employee_details table to demonstrate the IFNULL.
- Here we can see there is a null value in the reports_to column. Let us try to replace its value.
select * , IFNULL(reports_to,'37278') as null_fill from employee_details;
- We can see here that the null value part of the column is filled up with the specified value alternate for that.
- Log in to post comments