通过ODBC使用MS Access 2003进行嵌套的内部联接 [英] NESTED INNER JOIN using MS Access 2003 via ODBC

查看:103
本文介绍了通过ODBC使用MS Access 2003进行嵌套的内部联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这可行:

SELECT COUNT(t1.ID) AS count FROM Project t1
INNER JOIN (SELECT DISTINCT t.Site,t.id FROM _Equipment_id t WHERE t.OEM LIKE '%ABC%') t2 ON t1.Site=t2.Site AND t1.id=t2.id

这可行:

SELECT COUNT(t3.ID) AS count FROM Wall t3
INNER JOIN Project t1 ON t3.Project_number=t1.Project_number

为什么这个方法行不通:

Why doesn't this work:

SELECT COUNT(t3.ID) AS count FROM Wall t3
INNER JOIN Project t1 ON t3.Project_number=t1.Project_number
INNER JOIN (SELECT DISTINCT t.Site,t.id FROM _Equipment_id t WHERE t.OEM LIKE '%ABC%') t2 ON t1.Site=t2.Site AND t1.id=t2.id

最终,我有10个表(例如Wall表),我正尝试从第一个SELECT ...获得总计数.

Ultimately, I have 10 tables like the Wall table that I am trying to get a total count from the first SELECT....

推荐答案

SELECT COUNT(t3.ID) AS count FROM Wall t3
INNER JOIN (Project t1 
INNER JOIN (SELECT DISTINCT t.Site,t.id FROM _Equipment_id t WHERE t.OEM LIKE '%ABC%') t2 
ON t1.Site=t2.Site AND t1.id=t2.id)
ON t3.Project_number=t1.Project_number

也许这只是语法错误? Office帮助在底部提到嵌套.另一种可能性是,别名以某种方式限定了范围,因此它们对联接不可用,但是我不是MS Access方面的专家.也许您应该尝试完全删除别名.

Maybe it's just a syntax error? Office Help at the bottom where they mention nesting. The other possibility is that the aliases are somehow scoped so that they are not available to the join, but I'm no expert on MS Access. Maybe you should just try dropping the aliases altogether.

这篇关于通过ODBC使用MS Access 2003进行嵌套的内部联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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