我有一个名为tblIssueTicket的表 tblIssueTicket包含以下字段:TicketID,TicketRequesterID,ApprovalManagerID,RequestDate,ApprovalDate,TicketStatus
还有另一个名为tblEmployeeProfile的表。 tblEmployeeProfile包含字段EmployeeID,EmployeeFirstName,EmployeeLastName
我需要显示以下记录:
TicketID,TicketRequesterFullName,ApprovalManagerFullName,RequestDate,ApprovalDate,TicketStatus
我在查询查询以返回TicketRequester&的全名时遇到问题。 ApprovalManager字段的全名。
到目前为止,我的查询如下:
Select it.TicketID,
ep.Firstname + ' ' + ep.EmployeeLastName AS TicketRequestorFullName,
it.RequestDate, it.ApprovalDate, it.TicketStatus
FROM tblIssueTicket it, tblEmployeeProfile ep
WHERE ep.EmployeeID = it.TicketRequesterID
任何建议都会非常感激。
由于
CM
答案 0 :(得分:5)
SELECT
it.TicketID,
ep.Firstname + ' ' + ep.EmployeeLastName AS TicketRequestorFullName,
mp.Firstname + ' ' + mp.EmployeeLastName AS ApprovalManagerFullName,
it.RequestDate,
it.ApprovalDate,
it.TicketStatus
FROM
tblIssueTicket it
INNER JOIN tblEmployeeProfile ep ON ep.EmployeeID = it.TicketRequesterID
INNER JOIN tblEmployeeProfile mp ON mp.EmployeeID = it.ApprovalManagerID