我必须在3个条件下加入员工3次。我是否可以在3个条件下加入员工一次?
select
referType = resAffType,
referName = (case when resAffType = 0 then e.empFirstName + ' ' + e.empLastName
when resAffType = 1 then affFirstName + ' ' + affLastName
else NULL end),
bookName = e3.empFirstName + ' ' + e3.empLastName,
AssignToName = e2.empFirstName + ' ' + e2.empLastName,
from
Reservation r
left join ClubTable c on r.TableISN = c.TableISN
left join Affiliate a on r.AffiliateISN = a.AffiliateISN -- r.aff maybe in table aff
left join Employee e on r.AffiliateISN = e.EmployeeISN -- r.aff maybe in table emp
left join Employee e2 on r.EmployeeISN = e2.EmployeeISN -- assignedby emp
inner join Employee e3 on r.EmployeeISN = e3.EmployeeISN -- bookedby emp
答案 0 :(得分:0)
没有。你已经做的是正确的。