本文介绍了SQL-查找ADAM GRANT代理过的所有电影的电影名称和语言名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在用SQL来思考这样的问题时遇到了很多麻烦.我不知道应该如何构造查询.我应该在film_actor
上加入film
,然后在actor
上加入吗?还是我应该反过来做?
I'm having a ton of trouble thinking in terms of SQL on problems like this. I don't know how I should be structuring my queries. Should I be joining film
on film_actor
and then join that on actor
? Or should I do it the other way around?
我所能做的就是得到一个查询,该查询将actor
和film_actor
联接在一起,名称为ADAM GRANT
,但是我不知道该从哪里去.
All I've been able to do is get a query that joins actor
and film_actor
with the name ADAM GRANT
but I'm lost on where to go from here.
SELECT * FROM (actor JOIN film_actor ON actor.actor_id=film_actor.actor_id) WHERE first_name = 'ADAM' AND last_name = 'GRANT'
我尝试做一些事情来将这些结果与电影结合起来,但是我在语法上遇到了问题.
I've tried doing something to join these results with films, but I'm getting issues with my syntax.
SELECT title FROM (actor JOIN film_actor ON actor.actor_id=film_actor.actor_id) WHERE first_name = 'ADAM' AND last_name = 'GRANT' JOIN film ON film.actor_id = actor_id
推荐答案
您应该使用内部联接
SELECT
film.title
, language.name
FROM film
INNER JOIN language on film.language_id = language.language_id
INNER JOIN film_actor on film.film_id = film_actor.film_id
INNER JOIN actor on actor.actor_id = film_actor.actor_id
WHERE actor.first_name = 'ADAM'
AND actor.last_name ='GRANT'
这篇关于SQL-查找ADAM GRANT代理过的所有电影的电影名称和语言名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!