使用ADODB在VBA程序中查询Excel文件时,是否有多个JOIN不可用? [英] Are multiple JOINs unavailable when using ADODB to query an Excel file in a VBA procedure?

查看:252
本文介绍了使用ADODB在VBA程序中查询Excel文件时,是否有多个JOIN不可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3张数据格式为表格。表格名称为Riesgos,Eventos和EventosRiesgos。



EventosRiesgo具有与事件和风险相关的信息(多对多关系)。



我正在尝试从Riesgos获得所有的风险,但也是与(。我使用ADODB查询表作为数据库表并使用以下SQL的风险相关的事件:

  SELECT * FROM [Riesgos $] r 
LEFT JOIN [EventosRiesgos $]呃开启[Id] =呃[Id Riesgo]
LEFT JOIN [Eventos $] e ON呃[Id Evento] = e。[Id]
/ pre>

但是我收到一个错误,它是西班牙语,但粗略的翻译将是:表达式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?

解决方案

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]

这篇关于使用ADODB在VBA程序中查询Excel文件时,是否有多个JOIN不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆