substitution for NULL in SQL Server, Oracle, and MySQL

Source: Internet
Author: User
Tags expression numeric

What happens when SQL Server Oracle MySQL detects that a value is null in the database?

1, Mssql:isnull ()

Grammar

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

An expression to 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.

Comments

Returns the value of the expression if check_expression is not NULL, otherwise return replacement_value.

2, ORACLE:NVL ()

Grammar

NVL (EExpression1, EExpression2)

Parameters

EExpression1, EExpression2

If the eExpression1 evaluates to a null value, NVL () returns EEXPRESSION2. Returns EExpression1 if the result of the eExpression1 is not a null value. EExpression1 and EExpression2 can be any one of the data types. If the result of both EExpression1 and EExpression2 is null, then NVL () returns null

return value type

Character type, date type, datetime, numeric, currency, logical, or null value

Description

You can use NVL () to remove null values from calculations or operations without supporting null values or null values that are irrelevant.

3, Mysql:ifnull ()

Grammar

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.