我有两张桌子
国家表
Country region
AU ANZ
NZ ANZ规则表
Attr_1 Attr_2 Attr_3 Country
z 1 s AU
b 3 a AU
c 9 l NZ
m - i DE现在,我想编写一个查询,给出国家属于ANZ区域的所有行。例如,在上述情况下,除第4行外,其余3行国家为DE,不属于ANZ区域。这可以使用单个查询吗?
发布于 2015-09-13 08:11:33
您可以加入这些表,然后按国家表进行筛选:
SELECT Rules.*
FROM Rules
INNER JOIN Country ON Rules.Country = Country.Country
WHERE Country.Region = 'ANZ'发布于 2015-09-13 08:12:45
SELECT DISTINCT Attr_1, Attr_2, Attr_3, Country
FROM Country
INNER JOIN Rules
ON Country.Country=Rules.Country
WHERE Country.region='ANZ'https://stackoverflow.com/questions/32547609
复制相似问题