我有以下 SQL 语句:
select * from Leaves inner join LeaveDetails on Leaves.LeaveId= LeaveDetails.LeaveId
inner join Employee on Leaves.EmployeeCode = Employee.EmployeeCode
inner join LeaveType on Leaves.LeaveTypeId= LeaveType.LeaveTypeId
inner join LeaveStatus on Leaves.StatusId = LeaveStatus.StatusId
inner join Employee_organizationaldetails on Employee_organizationaldetails.EmployeeCode=Employee.EmployeeCode
where Leaves.LeaveId = 7295
Employee_organizationdetails 包含另一个名为报告官员的列,它是同一个 Employee 表的外键。现在我需要获取员工的姓名。
如何编写上述查询,以便在不获取执行查询的情况下获取报告官员的姓名作为另一列
select (FirstName + ' ' + LastName) as name from Employee where EmployeeCode = ReportingTo
这里的 ReportingTo 是员工代码。我需要垂直加入它们。类似于联合运算符的东西