For example, each movie has multiple tags, and each tag has multiple movies. The typical relationship is many-to-many. Therefore, I have created an intermediate table: fm_movie_tag, which has two fields: movie_id and tag_name. Movie_id and tag_name correspond to one table. For details about each movie...
For example, each movie has multiple tags, and each tag has multiple movies. A typical relationship is many-to-many. So I created an intermediate table: fm_movie_tag.
This table has two fields: movie_id and tag_name. Movie_id and tag_name correspond to one table.
For the data table fm_moviedetail with detailed information about each movie, you can set two fields: Region (movie_area) and age (movie_year ), now I want to query the sci-fi movies in Europe and America in 2015. How can I write this SQL statement?
Reply content:
For example, each movie has multiple tags, and each tag has multiple movies. A typical relationship is many-to-many. So I created an intermediate table: fm_movie_tag.
This table has two fields: movie_id and tag_name. Movie_id and tag_name correspond to one table.
For the data table fm_moviedetail with detailed information about each movie, you can set two fields: Region (movie_area) and age (movie_year ), now I want to query the sci-fi movies in Europe and America in 2015. How can I write this SQL statement?
SELECT md.name FROM fm_movie_tag AS fmtLEFT JOIN fm_moviedetail AS md ON md.id = fmt.movie_idLEFT JOIN fm_tagdetail AS td ON td.id = fmt.tag_idWHERE md.movie_area = 'xx' AND md.movie_year = 'xx' AND td.name = 'xx';
2015 is also a tag, isn't it simple? tag in (2015, Europe and America, science fiction)