Usage notes of not in Oracle

Source: Internet
Author: User

Today, I had to write this article for a long time because of a very strange problem.

  1. Select * from wlbtest3
  2. Where (sname, sage) not in (select user_name, user_age from wlbtest4)
  3. Select * from wlbtest3
  4. Where (sname | sage) not in (select user_name | user_age from wlbtest4)

Do you think the above two statements have the same effect?

You think that is the same and you are wrong !!! I thought it was the same at first. This is used at work, but the data is always not logical.

Finally let me find this place:

  1. Select * from wlbtest3
  2. Where (sname, sage) not in (select user_name, ''from wlbtest4)

What does the above sentence mean? You don't have to guess !!!

It means matching sname, but not matching sage, and the effect is the same as that below.

  1. Select * from wlbtest3
  2. Where (sname) not in (select user_name from wlbtest4)

So when the value of user_age is null, unexpected problems will occur... We recommend that you use "|.

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.