我看到有類似的問題,但沒有一個似乎有幫助。有人可以請解釋什麼是錯的這個查詢:SQL Server:無法綁定多部分標識符Select statement
SELECT
CH.ClaimNumber, CH.ClaimDate, CH.Warehouse, CH.SupplierNumber,
CH.SupplierName, CH.ControlAccount, CST.Status,
CD.Line, CD.HasGRN, CD.GRNNumber, CD.ItemCode, CD.ItemDescription,
CD.Price, CD.Quantity, CD.CreditValue,
CD.TaxCode, CD.TaxValue, CRS.Description, CD.IssueJournal, CD.CreditNote,
CD.SupplierNote, CD.Cancelled
FROM
CRClaimHeader AS CH, CRClaimDetail AS CD
INNER JOIN
CRStatusTypes AS CST ON CST.StatusID = CH.StatusFK
INNER JOIN
CRClaimReasons AS CRS ON CRS.ReasonCode = CD.ReasonCodeFK
WHERE
CH.ClaimNumber = @ClaimNumber
我就在這行錯誤:
ON CST.StatusID = CH.StatusFK
在CH.StatusFK
當我換寫的是什麼在此聲明:
FROM CRClaimHeader AS CH, CRClaimDetail AS CD
寫下來這樣:
FROM CRClaimDetail AS CD, CRClaimHeader AS CH
的錯誤轉移到該段:
ON CRS.ReasonCode = CD.ReasonCodeFK
在CD.ReasonCodeFK
難道您不錯過從ClaimDetail CD到ClaimHeader CH的連接嗎?而不是交叉連接? – StuartLC 2012-02-06 09:44:39
@nonnb是的,這兩張表格沒有關聯。謝謝。 – Cloud9999Strife 2012-02-06 10:27:29
@nonnb你可以列出上面的答案,我會接受它作爲答案。 – Cloud9999Strife 2012-02-07 06:55:36