使用ADODB在VBA程序中查询Excel文件时,是否有多个JOIN不可用? [英] Are multiple JOINs unavailable when using ADODB to query an Excel file in a VBA procedure?
问题描述
EventosRiesgo具有与事件和风险相关的信息(多对多关系)。
我正在尝试从Riesgos获得所有的风险,但也是与(。我使用ADODB查询表作为数据库表并使用以下SQL的风险相关的事件:
SELECT * FROM [Riesgos $] r
/ pre>
LEFT JOIN [EventosRiesgos $]呃开启[Id] =呃[Id Riesgo]
LEFT JOIN [Eventos $] e ON呃[Id Evento] = e。[Id]
但是我收到一个错误,它是西班牙语,但粗略的翻译将是:表达式r。[Id] =呃中的语法错误(缺少运算符)。 [Id Riesgo] LEFT JOIN [Eventos $] e ON呃[Id Evento] = e。[Id]
当我仅使用前2我的问题是:为什么当我使用两个JOIN时查询不起作用?
至少可以找到有关使用ADODB查询Excel表格的文档?
解决方案
访问Jet / ADODB / ACE喜欢带多个表的括号SELECT * FROM([Riesgos $] r
LEFT JOIN [EventosRiesgos $] er ON r。[Id] =呃[Id Riesgo])
LEFT JOIN [Eventos $] e ON呃[Id Evento] = e。[Id]
唯一的区别是
[riesgos $] r ....呃的括号[Id Riesggo]
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?
解决方案
AccessJet/ADODB/ACE likes brackets with multiple tablesSELECT * 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]
这篇关于使用ADODB在VBA程序中查询Excel文件时,是否有多个JOIN不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!