0

I have a workbook set up with 3 separate tabs/tables, and I am trying to do a 3 way LEFT JOIN query on this workbook (using SQL via the commandtext box on the ADODB connection in Excel 03), and I get a Syntax Error (Missing Operator) msgbox:

SELECT B.[Business], A.[book], C.[bus_area] 

FROM [Bon$] as A LEFT JOIN [DM$] as B ON (A.[book] = B.[SystemBookName] ) 
LEFT JOIN [BA$] as C ON B.[SystemBookName] = C.[portfolio_name]  

WHERE A.[area] NOT LIKE "%TEST%"

I know this is probably due to some syntax error/ or where I place the paranthesis, but I tried multiple combinations and it does not seem to work. Any ideas?

Many thanks

2
  • Remove the ( in FROM ([Bon$] Commented Sep 23, 2014 at 10:04
  • Thanks juergen - I have but still got an error. updated my post though. Commented Sep 23, 2014 at 11:06

1 Answer 1

2

Ah I figured out why. The code was thrown out because it saw it missing the operator FROM before the second LEFT JOIN. So I put in paranthesis everything after FROM and the second LEFT JOIN and it worked.

SELECT B.[Business], A.[book], C.[bus_area] 

FROM ([Bon$] as A LEFT JOIN [DM$] as B ON A.[book] = B.[SystemBookName] ) 
LEFT JOIN [BA$] as C ON B.[SystemBookName] = C.[portfolio_name]  

WHERE A.[area] NOT LIKE "%TEST%"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.