IFNULL(expr1,expr2)
Function description: If expr1 is null, the function returns expr2, otherwise it will Return expr1.
Example 1:
SELECT IFNULL(0,'ab');
The first parameter is 0, not NULL, so the result is 0.
Example 2:
SELECT IFNULL(NULL,'ab');
The first parameter is NULL, so the result is ab.
SELECT NULLIF(expr1,expr2)
Function description: If two If the two parameters are equal, NULL is returned; otherwise, the first parameter is returned.
Example 1:
SELECT NULLIF('a','b');
The two parameters are not equal, so the result is the first parameter a.
Example 2:
SELECT NULLIF('a','a');
The two parameters are equal, so the result is NULL.
SELECT ISNULL(expr)
Function description: If expr is null, then isnull() The return value is 1, otherwise the return value is 0.
Example 1:
SELECT ISNULL(NULL);
The parameter is NULL, so the result is 1.
Example 2:
SELECT ISNULL('ab');
The parameter is not NULL, so the result is 0.
The above is the detailed content of How to use IFNULL, NULLIF and ISNULL in MySql. For more information, please follow other related articles on the PHP Chinese website!