[英]Delete from table B where column value like table a with wildcards
So I have two tables所以我有两张桌子
seeds
- id
- domain
subdomain
- id
- domain
- ip
I want to filter the subdomains against the domains我想根据域过滤子域
for example例如
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
I'm trying to write a single query that deletes the rows in subdomain
that don't contain a domain
from seeds
我正在尝试编写一个查询来删除
subdomain
不包含来自seeds
的domain
的行
What have you tried?
你尝试过什么?
delete subdomain
where id not in
(select subs.id from seed as seeds
join
subdomain as subs on subs.domain
like concat('%', seeds.domain));
and和
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)
both of these queries just delete all of the rows这两个查询都只是删除所有行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.