Subtle differences in the use of SQL not in and not exists _mssql

Source: Internet
Author: User

The above two simple SQL, we understand from the surface, the final result of the query should be the same, but the actual result is not the same as we think

The result of the first SQL query has a single data

The result of the second SQL query is empty

Reason:

A subquery of not exists that is different for a subquery that does not return rows or rows returned by a subquery

These small differences must not be overlooked by us, and once the project is large, the time it takes to track down a specific error is considerable. Try to nip these unnecessary mistakes in the cradle.

Wordy, hehe.

The above two simple SQL, we understand from the surface, the final result of the query should be the same, but the actual result is not the same as we think

The result of the first SQL query has a single data

The result of the second SQL query is empty

Reason:

A subquery of not exists that is different for a subquery that does not return rows or rows returned by a subquery

These small differences must not be overlooked by us, and once the project is large, the time it takes to track down a specific error is considerable. Try to nip these unnecessary mistakes in the cradle.

Wordy, hehe.

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.