MySQL functions
The IFNULL () function for determining whether the first expression is NULL, if the second parameter is NULL value is returned, if not the first parameter is NULL return value.
IFNULL () function syntax is:
IFNULL(expression, alt_value)
If the first argument expression expression is NULL, the second alternate value of the parameter is returned.
Parameter Description:
parameter | description |
---|---|
expression | We must value to be tested |
alt_value | Must, expression expression is NULL return value |
Examples
The first argument is NULL:
SELECT IFNULL(NULL, "RUNOOB");
Examples of the above output is:
RUNOOB
The first parameter is not NULL:
SELECT IFNULL("Hello", "RUNOOB");
Examples of the above output is:
Hello