Get the App
SLTechnology News&Howtos  ›  Database  › 

Introduction to mysql Row Class View subquery

Shulou Source: shulou.com Published: 2022-06-01 20:58:46 10月04日 Update

In this article, we will learn about the introduction of mysql row-class view subquery. There is a certain reference value, friends in need can refer to, hope to help you.

Find the category name and number of movies that include robot in the description information, and also need the number of movies in this category > = 5

The film table is the movie table, the category table is the film classification table, and the film_category table is the intermediate table between the film table and the film classification table (many-to-many intermediate table)

Film table

CREATE TABLE IF NOT EXISTS film (film_id smallint (5) NOT NULL DEFAULT '0title varchar (255) NOT NULL,description text,PRIMARY KEY (film_id))

Category table

CREATE TABLE category (category_id tinyint (3) NOT NULL, name varchar (25) NOT NULL, `last_ update` timestamp,PRIMARY KEY (category_id))

Film_ chart

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 amountFROM 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 ccWHERE f.description LIKE'% robot%'AND f.film_id = fc.film_idAND fc.category_id = c.category_idAND c.category_id = cc.category_id

After reading the above, do you have a general understanding of the introduction to mysql row-class view subqueries? If you want to know more, welcome to follow the industry information channel.

Tags: Movies categories views queries references above and movies value information names numbers numbers articles more friends industry information channels channels subcontract Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB Redmi NVidia Apple