查找描述信息中包括robot的电影对应的分类名称以及电影数目,而且还需要该分类对应电影数量>=5部
film表为电影表,category表为电影分类表,film_category表为电影表与电影分类表的中间表(多对多的中间表)
film表
字段 |
说明 |
film_id |
电影id |
title |
电影名称 |
description |
电影描述信息 |
create table if not exists film (
film_id smallint(5) not null default '0',
title varchar(255) not null,
description text,
primary key (film_id));
category表
字段 |
说明 |
category_id |
电影分类id |
name |
电影分类名称 |
last_update |
电影分类最后更新时间 |
create table category (
category_id tinyint(3) not null ,
name varchar(25) not null, `last_update` timestamp,
primary key ( category_id ));
film_category表
字段 |
说明 |
film_id |
电影id |
category_id |
电影分类id |
last_update |
电影id和分类id对应关系的最后更新时间 |
create table film_category (
film_id smallint(5) not null,
category_id tinyint(3) not null, `last_update` timestamp);
select c.name, count(f.film_id) as amount
from film as f, film_category as fc, category as c,
(select category_id from film_category group by category_id having count(category_id) >= 5) as cc
where f.description like '%robot%'
and f.film_id = fc.film_id
and fc.category_id = c.category_id
and c.category_id = cc.category_id
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
Abp组织架构
实体Entity[Table("NovelPlayer")]public class Player : Enti...
[阅读全文]
-
-
-
-
分布式事务
分布式事务文章目录分布式事务一、分布式场景下的数据一致性问题形成原因剖析1. 分布式事务背景背景知识什么情况下会...
[阅读全文]
-
-
-
-
-
网友评论