【发布时间】:2018-08-16 06:03:46
【问题描述】:
我正在尝试在 FetchXML 中使用多个条件进行左外连接。
这是我想要实现的大致 SQL:
SELECT incident.*, externalCheck.*
FROM incident
LEFT OUTER JOIN externalCheck
ON externalCheck.incidentId = incident.incidentId
AND externalCheck.checkType = 1
AND externalCheck.isLatest = 1;
注意:这应该始终返回 1:1 的关系,因为我们的业务逻辑要求每个 checkType 只有一个 isLatest。
这是我的 FetchXML:
<entity name="incident">
<all-attributes />
<link-entity name="externalCheck" from="incidentId" to="incidentId" link-type="outer">
<filter type="and">
<condition attribute="checkType" operator="eq" value="1" />
<condition attribute="isLatest" operator="eq" value="1" />
</filter>
<all-attributes />
</link-entity>
</entity>
问题
问题是连接右侧为空的事件记录(即没有 externalCheck 记录)没有被返回,而在左外连接中,我希望即使连接的右侧为空,仍会返回事件记录。
我怀疑 FetchXML 将我的过滤器转换为 WHERE 子句,而不是将条件添加到 ON 子句。
问题
谁能确认发生了什么,以及可能的解决方案?
【问题讨论】:
标签: sql dynamics-crm fetchxml