2011-12-19 95 views
1

我想在代碼的末尾添加ADD。請對我的代碼一看,感謝您的支持:具有左外部連接和3個表的SQL

SELECT Area.org, 
    Supervisors.NomSup, 
    Supervisors.PrenomSup, 
    Employees.NomEmp, 
    Employees.PrenomEmp, 
    Employees.NoIdAlcanEmp, 
    Competencies.CodeCompetencies, 
    Competencies.CompetencyName, 
    LinkResultComp.AssNote, 
    LinkResultComp.AssDate 
FROM ((((((
     Area INNER JOIN Supervisors ON Area.IdArea = Supervisors.IdArea 
    ) 
     INNER JOIN Employees ON Supervisors.IdSupervisor = Employees.IdSupervisor 
    ) 
    INNER JOIN LinkProfilesEmployees ON Employees.IdEmp = LinkProfilesEmployees.IdEmp 
    ) 
    INNER JOIN Profiles ON Profiles.IdProfiles = LinkProfilesEmployees.IdProfiles 
    ) 
    INNER JOIN LinkProfComp ON Profiles.IdProfiles = LinkProfComp.IdProfiles 
) 
    INNER JOIN Competencies ON Competencies.IdCompetencies = LinkProfComp.IdCompetencies 
) 
LEFT OUTER JOIN LinkResultComp ON (Competencies.IdCompetencies = LinkResultComp.IdCompetencies AND ON Competencies.IdCompetencies = LinkResultComp.IdCompetencies) 

WHERE Area.org LIKE "*20*" AND Competencies.CodeCompetencies LIKE "khse2010-05" 
ORDER BY Supervisors.NomSup, Employees.NomEmp; 
+4

WTH是否「我想在我的代碼末尾添加ADD」是什麼意思? – Chandu 2011-12-19 19:43:07

+0

是的,它是AND – Daniel 2011-12-19 19:50:58

+0

LEFT OUTER JOIN LinkResultComp ON(Competencies.IdCompetencies = LinkResultComp.IdCompetencies AND ON Competencies.IdCompetencies = LinkResultComp.IdCompetencies) – Daniel 2011-12-19 19:51:38

回答

2

只是刪除您添加

額外ON所以改變這種

LEFT OUTER JOIN LinkResultComp 
ON (Competencies.IdCompetencies = LinkResultComp.IdCompetencies 
    AND ON Competencies.IdCompetencies = LinkResultComp.IdCompetencies) 
------^^ This one 

這個

LEFT OUTER JOIN LinkResultComp 
ON (Competencies.IdCompetencies = LinkResultComp.IdCompetencies 
    AND Competencies.IdCompetencies = LinkResultComp.IdCompetencies) 

當然,我認爲你的意思是不同的領域爲第二個條件