What is IFNULL
?
IFNULL
lets you replace NULL
values with a specified default value.
IFNULL(expression, replacement_value)
If expression
is truthy, it is used. If it’s falsy, the replacement_value
is used.
Examples
Example 1: Replace NULL
values with 0
SELECT IFNULL(NULL, 0)
Example 2: Replace NULL
values with a string
SELECT IFNULL(name, 'Unknown') FROM users;