如何组合左连接?
在 MS Access 2007 查询中,如何组合以下 2 个查询?
SELECT Tests.Release, Testcases.TestCase, Tests.Result
FROM Tests LEFT JOIN Testcases ON Tests.TestCaseID=Testcases.ID;
SELECT Tests.Release, ResultEnums.Result
FROM Tests LEFT JOIN ResultEnums ON ResultEnums.ID=Tests.Result;
谢谢
In MS Access 2007 query, how can I combine the following 2 queries?
SELECT Tests.Release, Testcases.TestCase, Tests.Result
FROM Tests LEFT JOIN Testcases ON Tests.TestCaseID=Testcases.ID;
SELECT Tests.Release, ResultEnums.Result
FROM Tests LEFT JOIN ResultEnums ON ResultEnums.ID=Tests.Result;
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Access 有这个糟糕的“功能”,它要求您将联接配对在括号中:
这种类型的查询可能会产生一些不好的结果,具体取决于架构。如果对于给定的
Tests
行,返回多个TestCases
行和多个ResultEnums
行,则这些行将通过叉积相互组合。例如,如果给定的Tests
行返回 5 个TestCases
行和 3 个ResultEnums
行,则您将获得该 Tests 行的 15 行。但是,如果ResultEnums
是Tests
表的父级(因此对于每一Tests
行,您只会获得一个ResultEnums值),那么这应该可以正常工作。
Access has this craptastic "feature" which requires you pair your joins in parentheses:
This type of query can produce some bad results depending on the schema. If for a given
Tests
row, multipleTestCases
rows and multipleResultEnums
rows are returned, those rows will be combined via a cross product with each other. For example, if a givenTests
row returned fiveTestCases
rows and threeResultEnums
rows, you will get 15 rows for that Tests row. However, if sayResultEnums
is parent to theTests
table (thus for everyTests
row, you would only get oneResultEnums
value), then this should work fine.我现在无法测试,但你肯定需要括号:
或
I can't test now but you surely need parenthesis:
or
一个非常天真的/简化的解决方案是简单地
UNION ALL
它们:编辑:更新在这里评论
我想这就是你想要的,来自
ResultEnums
表的Result
,从Tests
表中释放,并从Testcases
表中关联TestCase
,全部JOIN在他们的钥匙上:
A very naive/simplified solution would be to simply
UNION ALL
them:edit: update for comment here
I think this is what you want, the
Result
from theResultEnums
table, theRelease
from theTests
table, and the associatedTestCase
from theTestcases
table, allJOIN
ed on their keys:编辑 我没有在 Access 上进行测试,但在 SQL Server 中你可以做类似的事情。
EDIT I didn't test on Access, but in SQL Server you could do something akin to this.