访问db中的双内连接

时间:2012-04-26 11:16:33

标签: sql database ms-access

我需要从两个表,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

我尝试了很多方法,我在谷歌搜索过,但没有找到答案 如果有人有解决方案,我会非常感激

1 个答案:

答案 0 :(得分:7)

你用圆括号试过吗? 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