【发布时间】:2014-03-01 03:54:55
【问题描述】:
当我添加第二个 LEFT JOIN 语句时,为什么下面的查询会失败?错误状态为“无法绑定多部分标识符 T3.ConfigIDx”。在添加语句之前,T3.ConfigIDx 列显示在结果中。我尝试过使用和不使用 T3。
为简洁起见,我删除了 INNER JOINS 中的一些代码。
-- Add CfgDescription to ComponentID include QuantityWH for all components 'Used' or blank found in the order.
-- Attach Line information like Quantity and DiscountRate from the Order using Configuration ID.
SELECT
BDCComponentAttributes.componentID AS ComponentID,
BDCComponentAttributes.Value AS CfgDescription,
CAST (BDC10.Value AS INT) AS QuantityWH,
CfgIDx,
T3.ConfigIDx
FROM BDCComponentAttributes
Left join BDCComponentAttributes BDC10 on BDC10.ComponentID = BDCComponentAttributes.componentID and BDC10.ComponentAttributeName = 'QuantityWH'
Left join OrderDetails on OrderDetails.ConfigurationID = T3.ConfigIDx
INNER JOIN
(
-- Select ComponentID's and their respective CfgDescription for components found in order. This creates derived table T3.
INNER JOIN
(
-- Select Components in the order NOT 'NotUsed'. This creates derived table T2.
INNER JOIN
(
-- Select ConfigurationID's for components of the order. This creates derived table T1.
) AS T1
ON BDCComponents.CfgID = T1.CfgIDx
) AS T2
ON BDCComponentAttributes.ComponentID = T2.ComponentID
WHERE BDCComponentAttributes.ComponentAttributeName = 'PartInSystem' AND ( 'Used' = IsNull(BDCComponentAttributes.Value,'Used') OR BDCComponentAttributes.Value='Used')
) AS T3
ON BDCComponentAttributes.componentID = T3.ComponentID
WHERE BDCComponentAttributes.ComponentAttributeName = 'CfgDescription'
ORDER BY ComponentID
【问题讨论】: