本文介绍了用于geting EmpName,CreatedEmpName,UpdatedEmpName的SQL查询。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨专家,
Sql Table是这样的,
Ex:EmployeeTable(EmpId,EmpName,CreatedEmpId,updatedEmpId)
现在我的问题是如何获得EmpName,CreatedEmpName,UpdatedEmpName
提前感谢
问候
Sandeep Chowdary
hi Experts,
Sql Table was like this,
Ex: EmployeeTable (EmpId, EmpName, CreatedEmpId, updatedEmpId)
now my question is how to get EmpName,CreatedEmpName,UpdatedEmpName
thanks in advance
Regards
Sandeep Chowdary
推荐答案
SELECT EmpName, a.EmpName as CreatedEmpName, b.EmpName as UpdatedEmpName
FROM EmployeeTable e
LEFT JOIN EmployeeTable a ON e.CreatedEmpID = a.EmpID
LEFT JOIN EmployeeTable b ON e.updatedEmpId = b.EmpID
基本上,你只需两次加入同一个表,即可获得其他名称。
Essentially, you just join back to the same table twice to get the other names.
这篇关于用于geting EmpName,CreatedEmpName,UpdatedEmpName的SQL查询。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!