求解:服务器: 消息 301,级别 16 -- 查询中包含不允许的外联接请求
写了一条查询语句select course.name as coursename, score.sid as studentid, student.name as studentname, score.score as score, teacher.name as teachername from score,student,course,teacher where score.cid *= course.cid and score.sid *= student.sid and course.tid *=teacher.tid
SQL Server2000报错 查询中包含不允许的外联接请求
我将左连接的语法换成 left join on之后
select course.name as '课程名称', score.sid as '学号', student.name as '学生姓名', score.score as '分数', student.college as '所在学院',
teacher.name as '教师姓名' from score left join student on score.sid = student.sid left join course on score.cid = course.cid
teacher left join course on
course.tid = teacher.tid
仍然报错
服务器: 消息 170,级别 15,状态 1,行 3
第 3 行: 'teacher' 附近有语法错误。
简单描述一下,这个查询用到了四张表,score、course、student和teacher
score表的主键是sid(分数编号),course表的主键是cid(课程编号),student表的主键是sid(学号),teacher表的主键是tid(教师编号)
另外,score表中有cid和sid两个字段,作为外键与course表和student表连接,course表中有tid字段,作为外键与teacher表连接
这个查询需要获取与分数相关的信息,包括课程名(course表的name字段),学号(student表的sid字段),学生姓名(student表的name字段),分数(score表的score字段),教师姓名(teacher表的name字段)