0
爲什麼添加第二個LEFT JOIN語句時以下查詢失敗?錯誤狀態爲「多部分標識符T3.ConfigIDx無法綁定」。在添加語句之前,T3.ConfigIDx列顯示在結果中。我嘗試過,但沒有T3。添加LEFT JOIN導致「多部分標識符未綁定」
爲了簡潔起見,我在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
您建議在定義T3之後移動連接。我知道T3從第四行開始定義。所以我應該在那之後加入LEFT JOIN? – user3367179
我把它放在最後一個ON之後。它似乎工作。謝謝! – user3367179