mysql determine whether the field is null

There SQL ISNULL method described below:

ISNULL
replace the specified replacement value NULL.

语法
ISNULL ( check_expression , replacement_value )

Parameters
check_expression
will be checked against NULL. check_expression can be of any type.
replacement_value
in check_expression to NULL will return expression. replacement_value must have the same type check_expresssion.

E.g:

SELECT count(ISNULL(age,0))  FROM  Product;

However, in mysql, ISNULL only used to determine whether empty, replace function can not be achieved, according to the above write, directly error (Incorrect parameter count in the call to native function 'isnull' Errornumber: 1582).

So how to achieve Mysql SQL ISNULL method in it?
IFNULL (check_expression, replacement_value), ISNULL method implements SQL.

 Using the example above:

SELECT count(IFNULL(Weight, 50))  FROM  Product;

Guess you like

Origin blog.51cto.com/791165566/2421060