5

以下联接在 Access 中有效,但我需要添加第四个联接。

FROM ((Agents
LEFT JOIN Resignation_Pool    ON Agents.PF = Resignation_Pool.PF)
LEFT JOIN Teams               ON Agents.Team = Teams.ID)
LEFT JOIN Skills              ON Agents.PF = Skills.PF

当我添加第四个连接时,它不起作用。我知道 Access 对括号很奇怪,但我想我把它们放在它们所属的地方。查询只是永远运行,什么都不做(它根本不应该运行很长时间),我最终取消了它。有什么建议么?

FROM (((Agents
LEFT JOIN Resignation_Pool    ON Agents.PF = Resignation_Pool.PF)
LEFT JOIN Teams               ON Agents.Team = Teams.ID)
LEFT JOIN Skills              ON Agents.PF = Skills.PF)
LEFT JOIN OneMore             ON Agents.OM = OneMore.OM

这是有效的代码 - 我的实际查询而不是我发现的看起来相似的查询。

SELECT DISTINCT A02.PID, A02.PS, A02.PN, A02.PM, C01.RC, C01.IC, C01.RD 
INTO AutoCR 
FROM ((02_CorrectResults A02 
LEFT OUTER JOIN dbo_pol_PGI C01 
  ON (A02.PID = C01.PID and C01.PS = '999' and C01.PEDate >= #04/01/2012#)) 
LEFT OUTER JOIN dbo_pol_IL C02 
  ON C01.PID = C02.PID) 
LEFT OUTER JOIN dbo_pol_UN C03 
  ON C02.ILID = C03.ILID

我添加了另一个联接,但这不起作用。我尝试使用内部联接,但 Access 不喜欢那样。

SELECT DISTINCT A02.PID
, A02.PS
, A02.PN
, A02.PM
, C01.RC
, C01.IC
, C01.RD
, C04.CCode
, C04.PCode
, C04.CForm,
INTO AutoCR 
FROM (((02_CorrectResults A02 
LEFT OUTER JOIN dbo_rol_PGI C01 
  ON (A02.PID = C01.PID and C01.PS = '999' and C01.PEDate >= #04/01/2012#)) 
LEFT OUTER JOIN dbo_rol_IL C02 
  ON C01.PID = C02.PID) 
LEFT OUTER JOIN dbo_rol_UN C03 
  ON C02.ILID = C03.ILID) 
LEFT OUTER JOIN dbo_rol_HO C04 
  ON C03.UnID = C04.UnID
4

1 回答 1

6

您的查询中有尾随,。去掉它。

SELECT DISTINCT A02.PID
, A02.PS
, A02.PN
, A02.PM
, C01.RC
, C01.IC
, C01.RD
, C04.CCode
, C04.PCode
, C04.CForm,   <--- this was the problem
INTO AutoCR 
FROM (((02_CorrectResults A02 
LEFT OUTER JOIN dbo_rol_PGI C01 
  ON (A02.PID = C01.PID and C01.PS = '999' and C01.PEDate >= #04/01/2012#)) 
LEFT OUTER JOIN dbo_rol_IL C02 
  ON C01.PID = C02.PID) 
LEFT OUTER JOIN dbo_rol_UN C03 
  ON C02.ILID = C03.ILID) 
LEFT OUTER JOIN dbo_rol_HO C04 
  ON C03.UnID = C04.UnID
于 2014-05-12T22:18:38.927 回答