IFNULL()
The function determines whether the first expression is NULL, returns the value of the second parameter if it is NULL, and returns the value of the first parameter if it is not NULL.
IFNULL()
The function syntax format is:
IFNULL(expression, alt_value)
If the expression expression of the first parameter is NULL, the alternate value of the second parameter is returned.
参数说明:
Parameters. | Description |
|---|---|
expression | Must, the value to be tested |
alt_value | Must be the value returned when the expression expression is NULL |
Example ¶
The first parameter is NULL:
SELECT IFNULL(NULL, "RUNOOB");
The output result of the above example is:
RUNOOB
The first parameter is not NULL:
SELECT IFNULL("Hello", "RUNOOB");
The output result of the above example is:
Hello