Need MYSQL query for this scenario
Consider the following 2 tabls....
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
Now i want a query to find the movie names which has budget greater than titanic.
All movie names with their budget:
SELECT S.name, M.budget
FROM S
JOIN M ON M.no = S.no
Budget of Titanic:
SELECT M.budget
FROM S
WHERE S.Name = 'Titanic'
JOIN M ON M.no = S.no
All movie names which has budget greater than titanic:
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
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 = ?)
精彩评论