首页 > 数据库 >SQL Zoo 7.More JOIN operations

SQL Zoo 7.More JOIN operations

时间:2024-08-08 22:24:23浏览次数:18  
标签:operations casting title movie actor Zoo JOIN id select

以下数据均来自SQL Zoo

1.List the films where the yr is 1962 [Show idtitle](列出1962年的电影)

SELECT id, title
 FROM movie
 WHERE yr=1962

2.Give year of 'Citizen Kane'.(给出《公民凯恩》的年份)

select yr from movie where title = 'Citizen Kane'

3.List all of the Star Trek movies, include the id, title and yr. Order results by year.(列出所有星际迷航电影,包括id,标题和年份。按年排序结果)

select id,title,yr from movie 
where title like 'Star Trek%' order by yr

4.What id number does the actor 'Glenn Close' have?(演员格伦·克洛斯的身份证号码)

select id from actor where name = 'Glenn Close'

5.What is the id of the film 'Casablanca'.(电影《卡萨布兰卡》的主题)

select id from movie where title = 'Casablanca'

6.Obtain the cast list for 'Casablanca'.(获得《卡萨布兰卡》的演员名单)

select name from casting 
join actor on casting.actorid = actor.id where movieid = 11768

7.Obtain the cast list for the film 'Alien'.(获取电影《异形》的演员名单)

select name from actor 
join casting on actor.id = casting.actorid where movieid = 
(select id from movie where title = 'Alien')

8.List the films in which 'Harrison Ford' has appeared.(列出哈里森·福特出演过的电影)

select title from movie 
join casting on movie.id = casting.movieid
join actor on casting.actorid = actor.id
where name = 'Harrison Ford'

9.List the films where 'Harrison Ford' has appeared - but not in the starring role.(列出哈里森·福特出演过但不是主演的电影)

select title from movie 
join casting on movie.id = casting.movieid
join actor on casting.actorid = actor.id
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 movie.id = casting.movieid
join actor on casting.actorid = actor.id
where yr = 1962 and ord=1

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.(这是Rock Hudson最繁忙的年份,显示了他每年制作的电影数量,其中任何一年他制作了超过2部电影)

SELECT yr,COUNT(title) FROM
  movie JOIN casting ON movie.id=movieid
        JOIN actor   ON actorid=actor.id
WHERE name='Rock Hudson'
GROUP BY yr
HAVING COUNT(title) > 2

12.List the film title and the leading actor for all of the films 'Julie Andrews' played in.(列出朱莉·安德鲁斯出演的所有电影的片名和主演)

select distinct(title),name 
from movie join casting on movie.id=movieid
join actor on actorid=actor.id 
and ord=1
and movieid in (
  select t2.movieid 
  from actor t1  join casting t2 on t2.actorid=t1.id 
  and name='Julie Andrews')

13.Obtain a list, in alphabetical order, of actors who've had at least 15 starring roles.(按字母顺序获得一份出演过至少15个主演角色的演员名单)

select name from actor 
left join casting on actor.id = casting.actorid 
where ord=1 group by name having count(ord)>=15

14.List the films released in the year 1978 ordered by the number of actors in the cast, then by title.(按演员人数,再按片名,列出1978年上映的电影)

select title,count(actorid) from movie 
join casting on movie.id = casting.movieid and yr = 1978 
group by title 
order by count(actorid) desc,title 

15.List all the people who have worked with 'Art Garfunkel'.(列出所有与“Art Garfunkel”合作过的人)

select name from casting 
join actor on casting.actorid = actor.id 
where movieid in 
(select movieid from casting where actorid = 
(select id from actor where name = 'Art Garfunkel')) and name != 'Art Garfunkel'

标签:operations,casting,title,movie,actor,Zoo,JOIN,id,select
From: https://blog.csdn.net/weixin_61524392/article/details/141029732

相关文章

  • 防盗、防泄露、防篡改,我们把 ZooKeeper 的这种认证模式玩明白了
    作者:子葵你的ZooKeeper安全吗?在当下网络安全事件频发的背景下,安全防护的构建成为日常开发与运维工作中的重中之重。ZooKeeper存储着系统敏感实例信息与配置数据,但传统的使用方式并未为ZooKeeper配备强制身份验证机制,从而使得其内部数据面临暴露在网络空间中的风险。稍有不......
  • VMware Aria Operations 8.18 发布 (新增功能概览) - 多云 IT 运维管理
    VMwareAriaOperations8.18发布(新增功能概览)-多云IT运维管理通过统一的高性能平台,实现跨私有云、混合云和多云环境的IT运维管理。请访问原文链接:https://sysin.org/blog/vmware-aria-operations/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgVMwareAri......
  • zookeeper集群+kafka集群
    目录zookeeper集群概念数据流向图zookeeper集群实验架构实现步骤kafka集群概念消息队列的模式kafka的组件kafka的工作流程kafka集群实验创建主题生产者发布信息消费者订阅,消费信息查看topic当中的主题查看主题的详细信息删除主题修改分区数总结zookeepe......
  • 【YashanDB数据库】ycm托管数据库时报错OM host ip:127.0.0.1 is not support join to
    问题现象托管数据库时检查报错OM的IP是127.0.0.1,不支持托管到YCMOM问题的风险及影响导致数据库无法托管监控问题影响的版本问题发生原因安装数据库时修改了OM的监听ip为127.0.0.1解决方法及规避方式后台修改OM的ip为本机的ip或者0.0.0.0问题分析和处理过程1、修改en......
  • linux centos7部署zookeeper以及kafka
    一、部署zookeeper集群1.服务器配置,最好是在同一网段的IP服务器IP地址主机名node1192.168.116.6zknode1node2192.168.116.16zknode2node3192.168.116.26zknode31.1改主机名临时改主机名命令hostnametest1永久修改主机名hostnamectlset-hostnamezknode1注:要想更改后......
  • Machine Learning Operations
    MachineLearningOperationshttps://ml-ops.org/WithMachineLearningModelOperationalizationManagement(MLOps),wewanttoprovideanend-to-endmachinelearningdevelopmentprocesstodesign,buildandmanagereproducible,testable,andevolvableML-......
  • Zookeeper未授权访问漏洞
    Zookeeper未授权访问漏洞Zookeeper是分布式协同管理工具,常用来管理系统配置信息,提供分布式协同服务。Zookeeper的默认开放端口是2181。Zookeeper安装部署之后默认情况下不需要任何身份验证,造成攻击者可以远程利用Zookeeper,通过服务器收集敏感信息或者在Zookeeper集群内进......
  • Zookeeper之HA
    HA步骤配置之前先拍摄快照(重要)快照名称设置为Zookeeper配置免密登录#在node1节点执行ssh-keygen-trsa#三次回车之后ssh-copy-idnode1ssh-copy-idnode2ssh-copy-idmaster关闭所有Hadoop#关闭Hadoopstop-all.sh在core-site.xml中添加如下配置:--注......
  • mysql中的left join、right join 、inner join的详细用法
     1.innerjoin,内连接,显示两个表中有联系的所有数据。当两个表中存在匹配的数据时,‌返回满足条件的SELECT结果。‌内连接只返回两个表中匹配的记录,‌如果某一方没有匹配的记录,‌则不会出现在结果集中。‌2.leftjoin,左链接,以左表为参照,显示所有数据,右表中没有则以null显示......
  • mysql中的left join、right join 、inner join的详细用法
    1.innerjoin,内连接,显示两个表中有联系的所有数据。    当两个表中存在匹配的数据时,‌返回满足条件的SELECT结果。‌内连接只返回两个表中匹配的记录,‌如果某一方没有匹配的记录,‌则不会出现在结果集中。‌2.leftjoin,左链接,以左表为参照,显示所有数据,右表中没有......