【发布时间】:2011-07-19 12:56:00
【问题描述】:
我在 Access 中有一个小型数据库,除了以下问题外,它运行良好。数据库设计正确,其他 100 个查询都可以正常工作。我试图找到正确的 SQL 来返回正确的记录。肯定有符合 (((tblComorbidity.comorbidityexplanation)="infection" And (tblComorbidity.comorbidityexplanation)="pressure sores")) 的记录;部分,但由于某种原因,它什么也不返回。有什么建议么?谢谢
SELECT DISTINCT Person.PersonID, tblComorbidity.comorbidityexplanation
FROM
tblKentuckyCounties INNER JOIN
(tblComorbidity INNER JOIN (Person INNER JOIN tblComorbidityPerson ON Person.PersonID = tblComorbidityPerson.personID) ON tblComorbidity.ID = tblComorbidityPerson.comorbidityFK) ON tblKentuckyCounties.ID = Person.County
WHERE
(((tblComorbidity.comorbidityexplanation)="infection" And (tblComorbidity.comorbidityexplanation)="pressure sores"));
【问题讨论】:
-
你能给我们一些样本数据吗?它应该返回一些东西,但没有?
-
当然,如果 "And (tblComorbidity.comorbidityexplanation)="pressure sores"));"被删除它返回大约 100 条记录。如果您将上述语句中的压疮更改为“感染”,它还会返回大约 100 条记录。尽管有大约 70 条记录同时包含两者,但没有返回。
-
您需要调整此问题以反映您想要一个同时具备这两种合并症解释的人。
-
附带说明:我认为您在 WHERE 子句中的括号过分了...
-
您需要的关系运算符是division,俗称"the supplier who supplies all parts"。