我在查询中从表中提取数据时遇到问题,如果我在“品牌”中有一个空白字段,则返回所有结果。
我有两个查询,这是第一个,它基本上提取相同的数据但只返回Brand和Leader的ID号,而不是相关表中的已解析名称。
SELECT Review.ID, Review.Claim, [TSO Leader].LeaderID, Review.Consultant, Review.TSO, Review.[Claim Review Date], Review.Brand, Review.[Discussion Point], Review.[Review Notes], Review.[Review Decision], Review.Categories, Review.[Product Type]
FROM [TSO Leader] INNER JOIN Review ON [TSO Leader].LeaderID = Review.[TSO Leader]
ORDER BY [TSO Leader].LeaderID;
此查询提取已解决的“TSO Leader”和“Brand”,但如果该品牌为空,则不会返回结果。如何编辑它以显示品牌字段,即使它们为空。
这是第二个不从Brand中提取空字段的查询。
SELECT Review.ID, Review.Claim, Review.Consultant, Review.TSO, Review.[Claim Review Date], Review.[Discussion Point], Review.[Review Notes], Review.[Review Decision], Brand.Brand, Categories.Reason, [TSO Leader].LeaderName
FROM [TSO Leader] INNER JOIN (Categories INNER JOIN (Brand INNER JOIN Review ON Brand.BrandID=Review.Brand) ON Categories.CategoriesID=Review.Categories) ON [TSO Leader].LeaderID=Review.[TSO Leader];
编辑:从下面的Mitch的评论尝试通过外部联接扩展结果集但我收到语法错误。这是从。更新。
FROM [TSO Leader] INNER JOIN (Categories INNER JOIN (Brand FULL OUTER JOIN Review ON Brand.BrandID=Review.Brand) ON Categories.CategoriesID=Review.Categories) ON [TSO Leader].LeaderID=Review.[TSO Leader];
答案 0 :(得分:0)
我能够通过正确的连接来检索记录。访问一直抱怨说,我在正确的位置放置外连接是语法错误。当我从这里的文档http://office.microsoft.com/en-us/access-help/creating-an-outer-join-query-in-access-HA001034555.aspx
中读取时,访问应该使用外部联接SELECT Review.ID, Review.Claim, Review.Consultant, Review.TSO, Review.[Claim Review Date], Review.[Discussion Point], Review.[Review Notes], Review.[Review Decision], Brand.Brand, Categories.Reason, [TSO Leader].LeaderName
FROM [TSO Leader] INNER JOIN (Categories INNER JOIN (Brand RIGHT JOIN Review ON Brand.BrandID=Review.Brand) ON Categories.CategoriesID=Review.Categories) ON [TSO Leader].LeaderID=Review.[TSO Leader];