题解 | #使用子查询的方式找出属于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在线编程重点试题解析

