T-SQL not in encounters null implied trap

Source: Internet
Author: User

There are two T-SQL below, at first glance thought to be equivalent, but actually not

                         select  orderid1, Localcost,                                Supplygoodsname, Buyersgoodsid, Jsitid, Gsitid from  csc_  Result with  (NOLOCK) where  [level ] > 0  and  orderid1 like   ' 618464266 % '  and  (supplygoodsid  Not  in  (1085317 , 1112957 )) 

                         SELECTORDERID1, Localcost, Supplygoodsname, Buyersgoodsid, Jsitid, Gsit Id fromCsc_result with(NOLOCK)WHERE[ Level] >0                                     andOrderid1 like ' 618464266% '                                     and(Supplygoodsid not inch(1085317,1112957)ORSupplygoodsid is NULL)

Visible not in does not exclude null values

T-SQL not in encounters null implied trap

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.