一尘不染

Access数据库中的双重内部联接

sql

我需要从两个表(1个人,2个任务)中获取一些数据,SQL中的以下查询有效,并且Access不起作用

 SELECT     Task_Id,
            e2.emploeey_name AS W_FROM,
            e1.emploeey_name AS W_TO,
            t.Task_Details
 FROM       tasks AS T
 INNER JOIN Employees AS e1 ON e1.Emploeey_id = T.Task_To
 INNER JOIN Employees AS e2 ON e2.Emploeey_id = T.write_From

我尝试了很多方法,但我在Google中进行了搜索,但没有找到答案。如果有人有解决方案,我将非常感谢


阅读 146

收藏
2021-05-23

共1个答案

一尘不染

你用括号试过了吗?MS Access需要在多个JOINS周围加上(即喜欢)括号:

 SELECT     Task_Id,
            e2.emploeey_name AS W_FROM,
            e1.emploeey_name AS W_TO,
            t.Task_Details
 FROM       
 (
      tasks AS T
      INNER JOIN Employees AS e1 
           ON e1.Emploeey_id = T.Task_To
 )
 INNER JOIN Employees AS e2 
      ON e2.Emploeey_id = T.write_From
2021-05-23