MS Access的INNER JOIN问题

时间:2012-12-17 13:57:13

标签: sql ms-access inner-join

有人知道下面的查询中有什么不正确吗?

SELECT S1.[Company], COUNT(S1.[Milestone]) AS ShouldBeMilestones

FROM Sheet1 AS S1

INNER JOIN Sheet1 S2
ON S2.[Company] = S1.[Company]
AND S2.[Project] = S1.[Project]
AND S2.[Milestone] = 'Milestone 1'
AND S2.[%compl#] = 100

INNER JOIN Sheet1 S3
ON S3.[Company] = S1.[Company]
AND S3.[Project] = S1.[Project]
AND S3.[Milestone] = 'Milestone 2'
AND S3.[%compl#] = 100

WHERE ((S1.[Task class] <> 'A') AND (S1.[Task class] <> 'B') AND (S1.[Task class] <> ''))
AND S1.[Milestone] NOT LIKE '0.*' AND S1.[Milestone] NOT LIKE '1.*'
AND S1.[Start] <= Now()

GROUP BY S1.[Company];

在MS Access 2010中运行时,我收到“FROM子句中的语法错误”消息...

任何想法都会受到赞赏!

谢谢,

1 个答案:

答案 0 :(得分:0)

MS Access SQL很奇怪,你必须在多JOIN查询的JOIN周围加上括号。我讨厌这个功能,还没有解决它背后的“逻辑”。您可能有幸在Access query-builder中重新构建一个简单版本,然后编辑它而不会弄乱括号。