SQL IsNull (Oracle,mysql,mssql)

Source: Internet
Author: User
Tags mssql mysql tutorial

SQL IsNull (oracle,mysql tutorial, MSSQL)

IsNull
Replaces null with the specified replacement value.

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 be with

Check_expresssion has the same type.

return type
Returns the same type as check_expression.

Comments
Returns the value of the expression if check_expression is not null;

Replacement_value

Example
A. Use ISNULL with Avg
The following example finds the average price of all books and replaces the values in the $10.00 of the titles table with the

All null entries.

Use pubs
Go
Select AVG (IsNull (price, $10.00))
From titles
Go

Let's take a look at other database tutorials

Oracle
Oracle has no IsNull () function. However, we can use the NVL () function to achieve the same result:

Select Productname,unitprice* (UNITSINSTOCK+NVL (unitsonorder,0))
From Products
Mysql
MySQL also has functions similar to IsNull (). But the way it works with Microsoft's IsNull () function

A little different.

In MySQL, we can use the ifnull () function, just like this:

Select Productname,unitprice* (Unitsinstock+ifnull (unitsonorder,0))
From Products

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.