如何解决从表B中删除带有通配符的表a之类的列值
所以我有两个桌子
seeds
- id
- domain
subdomain
- id
- domain
- ip
我要针对域过滤子域
例如
seeds
Id Domain
0 google.com
1 test.com
subdomain
Id domain ip
0 test.google.com null
1 api.google.com null
2 dnr.com null
3 neveRSSl.com null
我正在尝试编写一个查询,以从subdomain
删除domain
中不包含seeds
的行
您尝试了什么?
delete subdomain
where id not in
(select subs.id from seed as seeds
join
subdomain as subs on subs.domain
like concat('%',seeds.domain));
和
delete subdomain
where id not in
(SELECT sd.id
FROM subdomain sd
LEFT JOIN seed s
ON sd.domain LIKE CONCAT('%',s.Domain)
WHERE s.id IS NULL)
解决方法
您可以使用not exists
:
delete from subdomain
where not exists (
select 1
from seeds s
where subdomain.domain like concat('%',s.domain)
)
,
使用LEFT JOIN
+ NULL
模式查找不匹配的行。
DELETE d
FROM subdomain AS d
LEFT JOIN seeds AS s ON d.domain LIKE CONCAT('%',s.domain)
WHERE s.id IS NULL
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。