" select语句包括拼写错误的保留字或参数名称"

时间:2018-06-14 19:28:31

标签: ms-access access-vba

我无法弄清楚为什么这条消息会一直出现。

  

select语句包含拼写错误的保留字或参数名称。

但是,我无法在代码中找到问题。

任何人都可以帮助并确定我缺少的是什么吗?

SELECT DISTINCT 
A.CINBR, SUM(C.EAANU) AS EAANU, SUM(C.MPRPQ) AS ONORD, 
   IIF(C.ITCLS = "DPAR","DPAR",""),
   IIF(C.ITCLS = "CONE","CONE",""),
   IIF(C.ITCLS = "PART","PART",""),
   IIF(C.ITCLS = "SPDY","SPDY",""),
FROM AMFLIB.PSTDTL A LEFT OUTER JOIN
    AMFLIB.ITEMBL C ON A.PINBR = C.ITNBR RIGHT OUTER JOIN
    INTonSHELF D ON A.CINBR = D .ITNBR
WHERE C.EAANU > 0
GROUP BY A.CINBR, C.ITCLS
ORDER BY A.CINBR

1 个答案:

答案 0 :(得分:1)

无视Access所说的内容,大部分时间都没有用。

据说以下是问题:

SELECT DISTINCT A.CINBR
    ,SUM(C.EAANU) AS EAANU
    ,SUM(C.MPRPQ) AS ONORD
    ,IIF(C.ITCLS = "DPAR", "DPAR", "")
    ,IIF(C.ITCLS = "CONE", "CONE", "")
    ,IIF(C.ITCLS = "PART", "PART", "")
    ,IIF(C.ITCLS = "SPDY", "SPDY", "")
FROM AMFLIB.PSTDTL A
LEFT JOIN AMFLIB.ITEMBL C ON A.PINBR = C.ITNBR
RIGHT JOIN INTonSHELF D ON A.CINBR = D.ITNBR
WHERE C.EAANU > 0
GROUP BY A.CINBR
    ,C.ITCLS
ORDER BY A.CINBR

具体来说,这一行导致了问题:IIF(C.ITCLS = "SPDY","SPDY",""), SELECT语句附加了一个额外的逗号。

此外,Access不支持LEFT OUTER JOINRIGHT OUTER JOIN作为功能