Comparison of Not In non-equal signs. It is better to use exits instead of in.

Source: Internet
Author: User

Comparison of Not In non-equal signs. It is better to use exits instead of in.

Not in will be converted into a series of and during parsing <>

Case 1

SELECT @results = count(filterCriterion_sv) FROM tbl_IN_VS_AND WHERE filterCriterion_sv NOT IN (214, 215, 216, 217)
Case 2
SELECT @results = count(filterCriterion_sv) FROM tbl_IN_VS_AND WHERE filterCriterion_sv <> 214   AND filterCriterion_sv <> 215 AND filterCriterion_sv <> 216 AND filterCriterion_sv <> 217

Case 3

SELECT @results = count(filterCriterion_sv) FROM tbl_IN_VS_AND LEFT OUTER JOIN ( SELECT 214 AS filterValue_val UNION SELECT 215 UNION SELECT 216 UNION SELECT 217 ) AS tbl ON tbl_IN_VS_AND.filterCriterion_sv = tbl.filterValue_val WHERE tbl.filterValue_val IS NULL

Case 4

SELECT @results = count(filterCriterion_sv) FROM tbl_IN_VS_AND WHERE NOT EXISTS(SELECT * FROM ( SELECT 214 AS filterValue_val UNION ALL SELECT 215 UNION ALL SELECT 216 UNION ALL SELECT 217 ) AS tbl WHERE tbl.filterValue_val = tbl_IN_VS_AND.filterCriterion_sv )



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.