当前位置:  开发笔记 > 编程语言 > 正文

SQL Query加入

如何解决《SQLQuery加入》经验,为你挑选了1个好方法。

我有一个名为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

任何建议都会非常感激.

谢谢

厘米



1> Mitch Wheat..:
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

推荐阅读
惬听风吟jyy_802
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有