Oracle "no equals" and nulls conditions

Source: Internet
Author: User

It was suddenly discovered today that the "not equal to operator" in Oracle ignores null.

For example, query comm is not equal to 300 of the records, I will take it for granted where comm! = 300

It is expected to return a record that contains null that is not equal to 300 (one of the cases where the consciousness considers null to be "not equal to 30").

In fact, it only returns records that are not null and not equal to 300, as shown in the following test.

Using Scott's common data test:

--All dataSelect *  fromscott.emp t;--Not equal (not contain null)Select *  fromScott.emp TwhereT.comm!=  -;--Not equal (Does contain null)Select *  fromScott.emp TwhereT.comm!=  - orT.comm is NULL; TEST

Returns only records with Comm not being null and not equal to 300.

In fact, it is not just the "no equals" relationship with NULL, but the other operators are similar, except that the "no equals" usage scenario makes it easy to detect this feature.

The reason for this is null, and the following Oracle documents are visible in the case of NULL:

Http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements005.htm

Http://www.cnblogs.com/nick-huang/p/3921605.html

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.