SELECT * FROM inscription i
INNER JOIN employeGroupe ge
ON i.IDGroupe=ge.IDGroupe
INNER JOIN Employe e
ON e.IDEmploye=ge.IDEmploye
INNER JOIN cOURS BC
on bc.IDCours=i.IDCours
我有4张桌子,如下所示:
Inscription
EmployeeGroupe
Employee
Cours
Column IDGroupe in table Inscription relates to table EmployeeGroupe
Column IDEmploe in table EmployeeGroupe relates to table Employee
Column IDCours in table Inscription relates to table Cours
我的问题是,我想显示相关雇员的姓名。我们可以在题词表中找到文字。不是说某些语言的INscription.IDGroupe为null,那么我就无法调出与EmployeGroupe相关的信息,该信息会在Employe表中上升到EmployeID。
我的查询是这样的:
SELECT * FROM inscription i
INNER JOIN employeGroupe ge
ON i.IDGroupe=ge.IDGroupe
INNER JOIN Employe e
ON e.IDEmploye=ge.IDEmploye
INNER JOIN cOURS BC
on bc.IDCours=i.IDCours
答案 0 :(得分:0)
尝试这样的事情
SELECT * from inscription I
LEFT JOIN employeGroupe ge
ON (ISNULL((i.IDGroupe),0) OR (i.IDGroupe = ge.IDGroupe))
LEFT JOIN Employe e
ON e.IDEmploye = ge.IDEmploye
LEFT JOIN cOURS bc
ON bc.IDCours = i.IDCours