-1

Its my second day with MS Access, i am trying to update an existing application. And this includes updating some queries. I never knew it was going to be so complex. the parenthesis issue in Access is really disturbing and i hit the wall, i get the "syntax error" error. My SQL query is something like this :

Select ….(Something)
Into …. (Some Table)
From A
Inner join B on A.ID=B.ID
LEFT OUTER JOIN STAR as C on C.ID = A.ID
    AND C.Data = ’DEMO1’
    AND C.POS= ’POS1’
LEFT OUTER JOIN STAR as D on D.ID = A.ID
    AND D.Data = ’DEMO2’
    AND D.POS= ‘POS2’
LEFT OUTER JOIN STAR as E on E.ID = A.ID
    AND E.Data = ’DEMO3’
    AND E.POS= ‘POS3’

And in access, its equivalent that i am trying is :

Select ….
Into ….
From (((A
Inner join B on A.ID=B.ID)
LEFT OUTER JOIN STAR as C (on C.ID = A.ID
    AND C.Data = ’DEMO1’
    AND C.POS= ’POS1’)
LEFT OUTER JOIN STAR as D (on D.ID = A.ID
    AND D.Data = ’DEMO2’
    AND D.POS= ‘POS2’)
LEFT OUTER JOIN STAR as E on E.ID = A.ID
    AND E.Data = ’DEMO3’
    AND E.POS= ‘POS3’
4

2 回答 2

0

考虑

Select ….
Into ….
From 
(A Inner join B on A.ID=B.ID) LEFT OUTER JOIN 
STAR as C on 
C.ID = A.ID AND 
((C.Data =  ’DEMO1’ AND C.POS= ’POS1’) OR
(C.Data =  ’DEMO2’ AND C.POS= ’POS2’) or
(C.Data =  ’DEMO3’ AND C.POS= ’POS3’))
于 2012-11-21T17:51:43.937 回答
0

终于通过括号了。

 Select ….
    Into ….
    From (((A
    Inner join B on A.ID=B.ID)
    LEFT OUTER JOIN STAR as C on (C.ID = A.ID
        AND C.Data = ’DEMO1’
        AND C.POS= ’POS1’))
    LEFT OUTER JOIN STAR as D on (D.ID = A.ID
        AND D.Data = ’DEMO2’
        AND D.POS= ‘POS2’))
    LEFT OUTER JOIN STAR as E on (E.ID = A.ID
        AND E.Data = ’DEMO3’
        AND E.POS= ‘POS3’)
于 2012-11-21T18:59:54.480 回答