2017-05-11 59 views
0

我無法查詢它顯示我的錯誤消息。無法綁定多部分標識符。 SQL服務器

Msg 4104,Level 16,State 1,Line 17多部分標識符 「D1.DesignationId」無法綁定。消息4104,級別16,狀態1, 行18多部分標識符「A.EmployeeId」無法綁定。 Msg 4104,Level 16,State 1,Line 18多部分標識符 「D1.EmpId」無法綁定。消息4104,級別16,狀態1,行21 無法綁定多部分標識符「A.EmployeeId」。

我的查詢代碼是:

SELECT  
    RequisitionAuthoritySignatury.ReqSampleDetailsId, 
    RequisitionAuthoritySignatury.ReqId, 
    D1.EmpName, 
    D1.DesignationId, 
    G.Name, 
    RequisitionAuthoritySignatury.PreparedBy 
FROM 
    RequisitionAuthoritySignatury 
    INNER JOIN AuthoritySignatury A ON RequisitionAuthoritySignatury.PreparedBy = A.AuthoritySignaturyId 
    INNER JOIN AuthoritySignatury B ON RequisitionAuthoritySignatury.PreparedBy = B.AuthoritySignaturyId 
    INNER JOIN AuthoritySignatury C ON RequisitionAuthoritySignatury.PreparedBy = C.AuthoritySignaturyId 
    INNER JOIN EmployeeMaster D1 
    INNER JOIN EmployeeMaster E 
    INNER JOIN EmployeeMaster F 
    INNER JOIN DesignationMaster G 
     ON D1.DesignationId = G.DesignationId 
     ON A.EmployeeId = D1.EmpId 
    INNER JOIN DesignationMaster H 
     ON E.DesignationId = H.DesignationId 
     ON A.EmployeeId = E.EmpId 
    INNER JOIN DesignationMaster I 
     ON F.DesignationId = I.DesignationId 
     ON A.EmployeeId = F.EmpId 
WHERE 
    RequisitionAuthoritySignatury.ReqId=158 AND 
    RequisitionAuthoritySignatury.ReqSampleDetailsId=260; 
+0

D1.DesignationId,D1.EmpId colud不意味着這些列不是該表EmployeeMaster –

+0

我沒有得到你的觀點可用。 –

回答

0

連接是「完成」,在其各自的ON條款出現的順序。每個ON子句「完成」最近的尚未完成的JOIN。由於您正在加入ON子句,因此在您引用D1時,將D1納入範圍的加入尚未完成,因此您會收到錯誤消息。移動你的ON年代到JOIN s表示,他們正試圖限制:

SELECT  
    RequisitionAuthoritySignatury.ReqSampleDetailsId, 
    RequisitionAuthoritySignatury.ReqId, 
    D1.EmpName, 
    D1.DesignationId, 
    G.Name, 
    RequisitionAuthoritySignatury.PreparedBy 
FROM 
    RequisitionAuthoritySignatury 
    INNER JOIN AuthoritySignatury A ON RequisitionAuthoritySignatury.PreparedBy = A.AuthoritySignaturyId 
    INNER JOIN AuthoritySignatury B ON RequisitionAuthoritySignatury.PreparedBy = B.AuthoritySignaturyId 
    INNER JOIN AuthoritySignatury C ON RequisitionAuthoritySignatury.PreparedBy = C.AuthoritySignaturyId 
    INNER JOIN EmployeeMaster D1 
     ON A.EmployeeId = D1.EmpId 
    INNER JOIN EmployeeMaster E 
     ON A.EmployeeId = E.EmpId 
    INNER JOIN EmployeeMaster F 
     ON A.EmployeeId = F.EmpId 
    INNER JOIN DesignationMaster G 
     ON D1.DesignationId = G.DesignationId 
    INNER JOIN DesignationMaster H 
     ON E.DesignationId = H.DesignationId 
    INNER JOIN DesignationMaster I 
     ON F.DesignationId = I.DesignationId 
WHERE 
    RequisitionAuthoritySignatury.ReqId=158 AND 
    RequisitionAuthoritySignatury.ReqSampleDetailsId=260; 
+0

謝謝@Damien_The_Unbeliever它正在爲我工​​作。 –

相關問題