我有两个表格,分别是Educational_Info和Employee_Info。这些表的详细信息如下。
表:Educational_Info
DegreeID DegreeName
1 BBA
2 BCA
3 MBA
4 MCA
表:Employee_Info
EmpID BachelorDegree MasterDegree
1001 2 4
期望的输出:
EmpID BachelorDegree MasterDegree
1001 BCA MCA
如何获得所需的输出。如果不能使用此表结构,请以任何其他方式建议我。
提前致谢。
答案 0 :(得分:1)
SELECT E.Empid,EI1.DegreeName,EI2.DegreeName
FROM Employee_info E
INNER JOIN Educational_Info EI1 ON E.BachelorDegree=EI1.Degreeid
INNER JOIN Educational_Info EI2 ON E.MasterDegree=EI2.Degreeid
答案 1 :(得分:1)
这个。这给你一些想法
select b.EmpID,a.DegreeName
FROM Educational_Info a
JOIN Employee_Info b on b.BachelorDegree = a.DegreeID or b.MasterDegree = a.DegreeID