如果我有这些关系:
我希望找到所有拥有没有参加比赛的马匹的所有者的名字。
这是我的解决方案:
select personName
from Owners
where horseName not in (select horseName from Results);
然而根据答题纸,他们喜欢这样:
select distinct personName
from Owners natural join Horses
left outer join Results on Horses.horseName = Results.horseName
where prizeMoney is null;
答案 0 :(得分:0)
你很好。他们的答案在很多方面都很糟糕 - 做一个自然的连接是不必要的,对性能不利,等等。
但是,您可能希望包含不同的内容,因为您撰写的查询可以(并且可能会)导致同一所有者被多次返回(对于他们拥有的每匹马而言,它都没有参加比赛)。