简体   繁体   English

mysql查询找到演员在两部电影中扮演的角色

[英]mysql query to find actors acted in both films

am trying to display actors acted in both films please help,it is not getting 我试图展示演员在两部电影中扮演的角色请帮忙,但是没有得到

SELECT actors.first_name,actors.last_name
FROM actors
LEFT JOIN films_actors
  ON actors.actor_id=films_actors.actor_id
LEFT JOIN films
  ON films_actors.film_id=films.film_id
WHERE films.title="ACADEMY DINOSAUR"
  AND films.title="ANACONDA CONFESSIONS"

You could use HAVING COUNT(DISTINCT ...) 你可以使用HAVING COUNT(DISTINCT ...)

SELECT actors.first_name,actors.last_name 
FROM actors 
JOIN films_actors 
  ON actors.actor_id=films_actors.actor_id
JOIN films 
  ON films_actors.film_id=films.film_id 
WHERE films.title IN ('ACADEMY DINOSAUR','ANACONDA CONFESSIONS')
GROUP BY actors.first_name,actors.last_name 
HAVING COUNT(DISTINCT films.title) = 2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 MySQL 按出演的电影类型列出演员 - List actors by genres of films they appeared in using MySQL SQL Sakila 查询问题 - 查找出演所有 16 部电影类别电影的所有演员 - SQL Sakila Query Question - Find all actors that have starred in films of all 16 film categories SQL-查找ADAM GRANT代理过的所有电影的电影名称和语言名称 - SQL - Find the film title and language name of all films in which ADAM GRANT acted 写一个查询,找到在mysql中出演电影数量第三多的演员的全名? - Write a query to find the full name of the actor who has acted in the third most number of movies in mysql? MySQL查询可查找演员姓名以B开头的电影的标题 - MySQL Query to find titles of movies with actors that have their name starting with B MYSQL:找出与 Nick Wahlberg 分享电影数量最多的五位演员(Sakila 数据库) - MYSQL: Identify the five actors who share the greatest number of films with Nick Wahlberg (Sakila Database) SQL 列出演员相同的字符不同的电影 - SQL List actors same char different films MySQL 查询 - 查找两种尺寸的饮料名称 - MySQL query - find name of beverages with both size 写一个查询,找到演过最多电影的演员的全名 - Write a query to find the full name of the actor who has acted in the maximum number of movies 如何在mysql中找到具有2个演员的电影标题? - how to find film title that have 2 actors in mysql?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM