开发者

Need MYSQL query for this scenario

开发者 https://www.devze.com 2023-03-31 07:30 出处:网络
Consider the following 2 tabls.... M.nobudgetcreated date 1250M2010 2210M2011 3200M1999 4开发者_如何学运维 150M1994

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 = ?)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号