需要SQL查询帮助才能查找电影

时间:2018-01-21 17:29:52

标签: sql

我需要有关SQL查询的帮助:如何查找已翻译超过4部电影的所有语言的列表,以及特定演员(例如Arnold Schwarzenegger)演奏的所有语言?

  • actor(actor_id,first_name,last_name)
  • director(director_id,first_name,last_name)
  • 电影(film_id,title,release_year,language_id,film_length,director_id,country_name)
  • film_actor(actor_id,film_id)
  • 语言(language_id,名称)
  • film_translation(film_id,language_id)

1 个答案:

答案 0 :(得分:0)

你可以试试这个。

SELECT l.language_id, l.name, COUNT(*) 
FROM 
    film_translation ft 
    INNER JOIn [language] l ON ft.language_id = l.language_id
    INNER JOIN [film] f on ft.film_id = f.film_id
    INNER JOIN [film_actor] fa on f.film_id = fa.film_id
    INNER JOIN [actor] a on fa.actor_id = a.actor_id
WHERE 
    a.first_name ='Arnold'
    and a.last_name  ='Schwarzenegger'
GROUP BY 
    l.language_id, l.name
HAVING 
    COUNT(f.film_id) > 4