组合多个连接

时间:2013-10-29 18:16:13

标签: sql oracle

所以,我有这个通过自然连接组合两个表的内联视图。我有一些条件可以使视图更易于管理。

Select * from student
natural join course
where student.stuNo = '838637'
and course.crsno = 'CS201'

现在,我想要使用另一个表从此视图执行左外连接。我收到一条错误信息,而对于我的生活,我无法弄清楚如何修复它。这是我的最后一个小贴士:

Select * from score2
left outer join (
Select * from student
natural join course
where student.stuNo = '838637'
and course.crsno = 'CS201') as Test1
on Test1.stuno = score2.studentNO

错误消息说我错过了一个关键字,但我无法弄清楚在哪里。有帮助吗?

1 个答案:

答案 0 :(得分:1)

关键字AS不应该在那里:

Select * from score2
left outer join (
Select * from student
natural join course
where student.stuNo = '838637'
and course.crsno = 'CS201') Test1
on (Test1.stuno = score2.studentNO)