为什么我在这些连接上出现语法错误?

时间:2014-03-25 17:00:43

标签: sql ms-access ms-access-2010

我正在接受

Syntax error in JOIN operation

此查询出错。这表明在连接中的某个地方有一个错位的括号,但我无法弄清楚出了什么问题。

select *
from
((ss
left join
sc
on
ss.guid=sc.guid)
left join
mrc
on
format(c.xDate, "yyyymmddHHMMSS")=mrc.xDate)
left join
c
on
sc.cID=c.id

1 个答案:

答案 0 :(得分:3)

您收到错误是因为c在定义之前被引用:

select *
from ((ss left join
       sc
       on ss.guid = sc.guid
      ) left join
      mrc
      on format(c.xDate, "yyyymmddHHMMSS") = mrc.xDate
----------------^
     ) left join
     c
     on sc.cID = c.id

您可以通过交换联接来解决此问题:

select *
from ((ss left join
       sc
       on ss.guid = sc.guid
      ) left join
      c
      on sc.cID = c.id
     ) left join
     mrc
     on format(c.xDate, "yyyymmddHHMMSS") = mrc.xDate