0

我有以下表格:

根据: id | domain

扩展: id | domain | country_code

国家: id | country_code | country_name

禁止域名: id | domain

我将在banned_domains 中拥有数千个(超过500K)的域。现在我需要获取禁止域列表中不存在的数据“域、国家代码和国家名称”。我不太擅长 MySQL JOINS,任何人都可以指导我进行正确的查询。

4

2 回答 2

1
SELECT b.domain, ex.country_code, c.country_name FROM base b 
INNER JOIN extended ex ON b.domain=ex.domain
INNER JOIN countries c ON ex.country_code=c.country_code
WHERE b.domain NOT IN (SELECT domain FROM banned_domains);
于 2012-09-23T12:12:24.580 回答
1

您可以使用此查询。

select b.domain , e.country_code , c.country_name from base b join  extended e on b.domain = e.domain join countries c on e.country_code = c.country_code and b.domain not in (select domain from banned_domains);

试试这个链接http://sqlfiddle.com/#!2/f78ea/1

于 2012-09-23T12:16:10.257 回答