我已经尝试过SQLiteSpy,SQLite Administrator和SQLite Expert Personal,但这些关键字似乎都没有。我正在关注Coursera上的数据库简介,教授正在使用Database Master进行查询。我无法使用该应用程序,因为我不断收到路径中非法字符的错误,所以我放弃了它。此外,它不是一个免费的应用程序。
在所有情况下,下面的代码块都会在“select”周围出错。如果我删除关键字,查询将运行但返回错误的结果。我不确定为什么它不起作用。有人知道吗?
无论如何,这是代码的一个例子......
select cName
from College C1
where enrollment > all ( select enrollment from College C2 where C2.cName <> C1.cName);
使用全部的另一个例子......
select College.cName, state, GPA
from College, Apply, Student
where College.cName = Apply.cName
and Apply.sID = Student.sID
and GPA >= all
(select GPA from Student, Apply
where Student.sID = Apply.sID
and Apply.cName = College.cName);
最后一个例子是使用任何......
select cName
from College S1
where not enrollment <= any (select enrollment from College S2 where S2.cName <> S1.cName);
答案 0 :(得分:0)
我发现any
和all
在理解查询时非常有用。您可以将查询重写为:
select cName
from College C1
where enrollment > ( select max(enrollment) from College C2 where C2.cName <> C1.cName);
select College.cName, state, GPA
from College join
Apply
on College.cName = Apply.cName join
Student
on Apply.sID = Student.sID
where GPA >= (select max(GPA)
from Student join
Apply
on Student.sID = Apply.sID
where Apply.cName = College.cName
);
最后一点有点难以理解。我认为是:
select cName
from College S1
where enrollment > (select max(enrollment) from College S2 where S2.cName <> S1.cName);
作为奖励,我还将查询更改为使用显式join
语法而不是where
子句中的隐式连接。