4

I have 3 sheets with data formatted as tables. The sheets names are "Riesgos", "Eventos" and "EventosRiesgos".

EventosRiesgo has information relating events and risks (many to many relationship).

I'm trying to get all the risks from Riesgos, but also the events related to the risks from (. I'm using ADODB to query the sheets as database tables and using the following SQL:

SELECT * FROM [Riesgos$] r
LEFT JOIN [EventosRiesgos$] er ON r.[Id]=er.[Id Riesgo]
LEFT JOIN [Eventos$] e ON er.[Id Evento]=e.[Id]

But i get an error, it's in Spanish but a rough translation would be: Syntax error (missing operator) in expression "r.[Id]=er.[Id Riesgo] LEFT JOIN [Eventos$] e ON er.[Id Evento]=e.[Id]"

When I run the query only using the first 2 lines (only one join) everything works as expected. My question is: Why is the query not working when I use the two JOINs?

Can anyone help me, at least to find documentation on the use of ADODB to query Excel sheets?

3

1 Answer 1

9

Access Jet/ADODB/ACE likes brackets with multiple tables

SELECT  * FROM ( [Riesgos$] r
LEFT JOIN [EventosRiesgos$] er ON r.[Id]=er.[Id Riesgo] )
LEFT JOIN [Eventos$] e ON er.[Id Evento]=e.[Id]

The only difference is brackets around the [riesgos$] r .... er.[Id Riesggo]

Sign up to request clarification or add additional context in comments.

2 Comments

It seems that the maximum number of left joins is 8, can somebody confirm / explain this ?
@stef, 2007 16, 2010 16, but both say may be less if the query includes multivalued lookup fields.

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.