gpt4 book ai didi

sql-server - T-SQL : [column] not like [any value from another select]

转载 作者:行者123 更新时间:2023-12-01 06:17:36 24 4
gpt4 key购买 nike

我的表 shop 有一个 Email 列。

我还有另一个表 Unsubscribed,其中包含 EmailPattern 列。

如何只选择 Email 列与 Unsubscribed 表中的任何 EmailPattern 值不匹配的商店?

例子:

退订有这些记录:

aaa
bbb
ccc

我期望这样的结果:

select * 
from Shop
where Email not like "%aaa%"
and Email not like "%bbb%"
and Email not like "%ccc%"

最佳答案

Select *
From shop
Where not exists (
Select 1
From unsubscribed
Where shop.email like '%' + unsubcribed.emailpattern + '%'
)

关于sql-server - T-SQL : [column] not like [any value from another select],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20180711/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com