How can I perform a SQL 'NOT IN' query faster?

前端 未结 3 833
夕颜
夕颜 2021-01-01 18:35

I have a table (EMAIL) of email addresses:

EmailAddress
------------
jack@aol.com
jill@aol.com
tom@aol.com
bill@aol.lcom

and a table (BLACK

3条回答
  •  走了就别回头了
    2021-01-01 19:00

    select E.EmailAddress
      from EMAIL E where not exists
             (select EmailAddress from BLACKLIST B where B.EmailAddress = E.EmailAddress)
    

    Equals (BTW there is probably an owner)

    select EmailAddress from mail.EMAIL 
    EXCEPT
    select EmailAddress from mail.BLACKLIST 
    

    will give you the rows that are different even if NULL in an EmailAddress

提交回复
热议问题