SQL Server, Oracle, and MySQL methods for judging null
This article covers SQL Server, Oracle, and MySQL to isolate null replacement values.
What if a value of NULL is found in the SQL Server Oracle mysql database?
1, Mssql:isnull ()
Grammar
Java Code
Copy CodeThe code is as follows:
ISNULL (Check_expression, Replacement_value)
ISNULL (Check_expression, Replacement_value)
Parameters
check_expression
An expression that will be checked for null. Check_expression can be of any type.
Replacement_value
The expression that will be returned when check_expression is null. Replacement_value must have the same type as check_expresssion.
return type
returns the same type as check_expression.
Notes
if Check_expression is not NULL, the value of the expression is returned, otherwise Replacement_value is returned.
2, ORACLE:NVL ()
Grammar
Java Code
Copy CodeThe code is as follows:
NVL (EExpression1, EExpression2)
NVL (EExpression1, EExpression2)
Parameters
EExpression1, EExpression2
if the eExpression1 evaluates to a null value, NVL () returns EEXPRESSION2. If the EExpression1 evaluates to a value other than NULL, the EExpression1 is returned. EExpression1 and EExpression2 can be any data type. NVL () returns null if the result of both EExpression1 and EExpression2 is a null value
return value type
character, date, datetime, numeric, currency, logical, or null values
Description
You can use NVL () to remove null values from a calculation or operation in cases where null values are not supported or if NULL values do not matter.
3, Mysql:ifnull ()
Grammar
Java Code
Copy CodeThe code is as follows:
Ifnull (EXPR1,EXPR2)
Ifnull (EXPR1,EXPR2)
Parameters
EXPR1,EXPR2
if EXPR1 is not Null,ifnull () returns EXPR1, it returns EXPR2. Ifnull () returns a numeric or string value, depending on the context in which it is used
SQL Server, Oracle, and MySQL methods for judging null