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

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

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

首先,查询出Action的类别id

select category_id from category where name = 'Action';-- 返回1

第二,拿着Action的类别id,去查询属于该类别的电影id

select film_id from film_category where category_id = (select category_id from category where name = 'Action');

第三,去film表中查询

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

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务