Return a specified value if the expression is NULL; otherwise, return the expression.
SELECT IFNULL(NULL, “W3Schools.com”); |
The IFNULL() function returns a specified value if the expression is NULL.
If the expression is NOT NULL, it returns the expression itself.
IFNULL(expression, alt_value) |
Parameter |
Description |
expression |
Required. The expression to check for NULL. |
alt_value |
Required. The value to return if the expression is NULL. |
Works in: |
From MySQL version 4.0 |
Return the specified value if the expression is NULL; otherwise, return the expression itself.
SELECT IFNULL(“Hello”, “W3Schools.com”); |
Return the specified value if the expression is NULL; otherwise, return the expression.
SELECT IFNULL(NULL, 500); |