考虑以下2个表格....
M.no budget created date
1 250M 2010
2 210M 2011
3 200M 1999
4 150M 1994
S.no Name
1 Avator
2 Transformers
3 Titanic
4 Dark knight
现在我想要一个查询来查找 预算大于 的电影名称。
答案 0 :(得分:0)
select m.name
from movies m inner join budgets b on (b.no = m.no)
where b.budget > (select budget
from from movies mm inner join budgets bb on (bb.no = mn.no)
where mm.name = ?)
答案 1 :(得分:0)
所有电影名称及其预算:
SELECT S.name, M.budget
FROM S
JOIN M ON M.no = S.no
泰坦尼克号的预算:
SELECT M.budget
FROM S
WHERE S.Name = 'Titanic'
JOIN M ON M.no = S.no
预算超过泰坦尼克号的所有电影名称:
SELECT S.name
FROM S
WHERE M.budget > (
SELECT M.budget
FROM S
WHERE S.Name = 'Titanic'
JOIN M ON M.no = S.no
)
JOIN M ON M.no = S.no