[英]How to get data from two different tables using stored procedures?
I am new to functions so am having a bit starting trouble here 我是新手,所以这里有点麻烦
I have two tables like this 我有两张这样的桌子
Bugs 错误
BugID | Title | ProjectName | CreatedBy
BugHistory BugHistory
BughistoryID | BugID | Assignedto | ToStatus | FromStatus
EmployeeTable EmployeeTable中
EmployeeID | EmployeeName |
[AssignedTo]
column from BugHistory
is a foreign key for [EmployeeId]
in EmployeeTable
. [AssignedTo]
从塔BugHistory
为外键[EmployeeId]
在EmployeeTable
。
I want a select statement where I have to show the bugs table in gridview with [AssignedTo]
and [Tostatus]
columns from BugHistory
table. 我想一个select语句,我必须展示在GridView控件与错误表
[AssignedTo]
和[Tostatus]
从列BugHistory
表。 How can I use functions for this both procedure s any ideas please? 我怎样才能使用这两个程序的功能呢?
In Assigned to
column I want the name of the employee - how can I map this? 在
Assigned to
列中,我想要员工的姓名 - 我该如何映射?
It sounds like you want this: 听起来你想要这个:
SELECT b.BugId
, b.Title
, b.ProjectName
, b.CreatedBy
, e.EmployeeName As AssignedTo
, bh.ToStatus
FROM Bugs b
INNER JOIN BugHistory bh
ON b.bugid = bh.bugid
INNER JOIN Employee e
ON bh.AssignedTo = e.EmployeeId
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.