我是oracle sql的新手。我正在尝试执行以下查询
SQL> select movie.movie_title, movie.release_year, cast.movie_title, cast.release_year
from MOVIE movie, CAST_MEMBER cast
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
查询有效如果我没有加入actor表但我试图从ACTOR表中提取actor名称。我看过其他问题,但无法修复。如果有人可以指导我出错的地方。
谢谢
答案 0 :(得分:2)
where子句必须在所有连接之后出现。
select movie.movie_title, movie.release_year, cast.movie_title, cast.release_year
from MOVIE movie, CAST_MEMBER cast
join ACTOR actor on(actor.actor_name = cast.actor_name)
where movie.movie_title = cast.movie_title and movie.release_year = cast.release_year
group by cast.movie_title, cast.release_year, cast.actor_name;
另外,你不应该混合两个连接符号,所以最好写:
select movie.movie_title, movie.release_year, cast.movie_title, cast.release_year
from MOVIE movie
join CAST_MEMBER cast on (movie.movie_title = cast.movie_title and movie.release_year = cast.release_year)
join ACTOR actor on(actor.actor_name = cast.actor_name)
group by cast.movie_title, cast.release_year, cast.actor_name;
答案 1 :(得分:2)
我建议您不要混合使用连接语法:
select distinct
movie.movie_title, movie.release_year,
cast.movie_title, cast.release_year
from MOVIE movie
inner join CAST_MEMBER cast
on movie.movie_title = cast.movie_title and movie.release_year = cast.release_year
inner join ACTOR actor
on actor.actor_name = cast.actor_name;
我还删除了该组,并将其替换为不同的