SQLZOO 7 More JOIN

1.List the films where the yr is 1962 [Show id, title]

列出年份为1962年的电影[Show id, title]

select id,title from movie where yr = '1962'
2.Give year of ‘Citizen Kane’.

查询出电影’Citizen Kane’的上映年份

select yr from movie where title = 'Citizen Kane'
3.List all of the Star Trek movies, include the id, title and yr (all of these movies include the words Star Trek in the title). Order results by year.

列出所有星际旅行电影,包括id,title,yr(所有的星际旅行电影名都包含Star Trek字符串),将结果按照年份排序

select id,title,yr from movie
where title like '%Star Trek%' order by yr
4.What id number does the actor ‘Glenn Close’ have?

演员 'Glenn Close’的id是多少

select id from actor where name='Glenn Close'
5.What is the id of the film ‘Casablanca’.

电影 'Casablanca’的id是多少

select id from movie where title like 'Casablanca'
6.Obtain the cast list for ‘Casablanca’.

获取电影’Casablanca’的演员名单

select name from actor
join casting on actorid = id 
where movieid = (select id from movie where title = 'Casablanca')
7.Obtain the cast list for the film ‘Alien’

获取电影’Alien’的演员名单

select name from actor 
join casting on actorid=id 
where movieid = (select id from movie where title = 'Alien')
8.List the films in which ‘Harrison Ford’ has appeared

列出’Harrison Ford’出演过的电影

select title from movie
join casting on movieid = id 
where actorid = (select id from actor where name = 'Harrison Ford')
9.List the films where ‘Harrison Ford’ has appeared - but not in the starring role. [Note: the ord field of casting gives the position of the actor. If ord=1 then this actor is in the starring role]

列出’Harrison Ford’ 出演过的电影,但不要是主演。[注意:actor表的ord字段给出了演员的位置。如果ord=1,则该演员为主演]

select title from movie join casting on movieid=id
where actorid = 
(select id from actor where name = 'Harrison Ford') and ord <> 1
10.List the films together with the leading star for all 1962 films.

列出1962年所有电影的电影和主演

select title,name from movie
join casting on movieid = movie.id 
join actor on actor.id = actorid 
where ord=1 and yr = 1962
11.Which were the busiest years for ‘Rock Hudson’, show the year and the number of movies he made each year for any year in which he made more than 2 movies.

哪一年是“洛克·哈德森”最繁忙的年份,展示这一年以及他每年制作的电影数量,如果他制作的电影超过2部

select yr,count(title) from movie
join casting on movieid = movie.id
join actor on actorid = actor.id
where casting.actorid = 
(select id from actor where name = 'Rock Hudson')
group by yr having count(title) > 2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

念犯困

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值