题解 | #使用子查询的方式找出属于Action分类的所有电影对应的title,description#

使用子查询的方式找出属于Action分类的所有电影对应的title,description

http://www.nowcoder.com/practice/2f2e556d335d469f96b91b212c4c203e

select title, description
from film
where film_id in
(select film_id
from film_category
where category_id in
(select category_id
from category
where name = 'Action'));

解题思路 从内到外,依次嵌套。

-- 第一步:找出Action对应的category_id
select category_id
from category
where name = 'Action';

-- 第二步:找出category_id对应的film_id
select film_id
from film_category
where category_id in
(select category_id
from category
where name = 'Action');

-- 第三步: 找出film_id对应的title,description
select title, description
from film
where film_id in
(select film_id
from film_category
where category_id in
(select category_id
from category
where name = 'Action'));
MySQL试题答案解析 文章被收录于专栏

MySQL在线编程重点试题解析

全部评论

相关推荐

迷茫的大四🐶:那你问他上班之后老实了没
点赞 评论 收藏
分享
牛客21331815...:像我一投就pass,根本不用焦虑泡池子
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务