编辑:答案:
SELECT c.Name FROM Country c
WHERE NOT EXISTS
( SELECT * FROM City
JOIN Building ON City.CityID = Building.CityID
WHERE City.CountryID = c.CountryID);
谢谢您的宝贵时间。
我有这样的架构:
我这样做是为了选择所有没有建筑物的城市。
select * from City c
left join Building b on b.CityID = c.CityID
where b.CityID is null or c.CityID is null
union all
select * from City c
right join Building b on b.CityID = c.CityID
where b.CityID is null or c.CityID is null;
如何选择没有建筑物的国家名称?
2,产量预期:英国
试试这个告诉我
select * from country where CountryID not in
(select CountryID from country as c join city as t on c.CountryID =t.CountryID join building as b on t.CityID = b.CityID )
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句