Question
J'ai une table appelée tblIssueTicket tblIssueTicket contient les champs: TicketID, TicketRequesterID, ApprovalManagerID, RequestDate, ApprovalDate, TicketStatus
Il existe une autre table appelée tblEmployeeProfile. Le fichier tblEmployeeProfile contient les champs EmployeeID, EmployeeFirstName, EmployeeLastName
.Je dois afficher les enregistrements suivants:
TicketID, TicketRequesterFullName, ApprovalManagerFullName, RequestDate, ApprovalDate, TicketStatus
Je ne parviens pas à trouver le nom complet du TicketRequester & amp; nom complet des champs ApprovalManager.
Ma requête jusqu'à présent ressemble à ceci:
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
Tout conseil serait grandement apprécié.
Merci
CM
La solution
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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow