Description
Returns the first non-null value — expression when it is not NULL, otherwise fallback.
Syntax
IFNULL(expression, fallback)
Parameters
| Parameter | Description | Data Type | Required |
|---|---|---|---|
| expression | Value to return when it is not NULL | Any | Yes |
| fallback | Value to return when expression is NULL | Any | Yes |
Notes
- Behaves like
COALESCE(expression, fallback); parser normalizes toCOALESCE.
Example
SELECT
IFNULL(NULL, 'fallback')
FROM
my_table t
LIMIT
1;