【问题标题】:outer join more than 2 tables in access在访问中外连接超过 2 个表
【发布时间】:2015-05-27 22:40:32
【问题描述】:

关注this 线程后。我收到“JOIN 操作中的语法错误”错误

这是我的查询

SELECT 
    StudentMaster.Student_id, 
    ExamDetails.Subject_id, 
    SubjectMaster.Subject_id 
FROM 
    (StudentMaster 
     LEFT OUTER JOIN ExamDetails 
       ON StudentMaster.Student_id = ExamDetails.Student_id) 
    LEFT OUTER JOIN ExamDetails 
      ON SubjectMaster.subject_id = ExamDetails.Subject_id

对此的任何帮助都将是可观的

【问题讨论】:

  • 你想从表中得到什么结果。
  • 您有ON SubjectMaster.subject_id = ...,但在FROM 子句中没有定义SubjectMaster 表(但您已加入ExamDetails 两次)。我猜第二个加入应该是LEFT OUTER JOIN SubjectMaster
  • 我想要学生列表以及与学生相关的科目以及考试详细信息中的记录
  • 会不会是括号引起了问题?

标签: ms-access outer-join


【解决方案1】:

你试过这个吗?

select s.Student_id,e.Subject_id,sub.Subject_id
from YourDatabaseName.SubjectMaster as sub 
left outer join YourDatabaseName.ExamDetails as e 
    on sub.Subject_id=e.Subject_id
left outer join YourDatabaseName.StudentMaster as s
    on s.Student_id=e.Student_id
group by s.Student_id
order by s.Student_id;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-29
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    相关资源
    最近更新 更多