有两个样本表
tblEmployee
tblProjectDetails
在连接两个表时如何获得所需的输出,如最终表中所示?需要SQL查询?或者在C#和.net中完成任何其他更好的事情。
tblEmployee
EMP_ID EMP_Name EMP_Email
1 Hanu hanu@gmail.com
2 Chetan chetan@gmail.com
3 Vishal vishal@yahoo.com
tblProjectDetails
EMP_ID EMP_ProjectName EMP_ProjectDetails
1 Project1 Asset Management
1 Project2 Inventory Mangament
2 Project3 PMT
2 Project4 Stores Managemnt
3 Project5 RFID
tblResult
EMP_ID EMP_Name EMP_Email EMP_ProjectName EMP_ProjectDetails
1 Hanu hanu@gmail.com Project1 Asset Management
Project2 Inventory Mangament
2 Chetan chetan@gmail.com Project3 PMT
Project4 Stores Managemnt
3 Vishal vishal@yahoo.com Project5 RFID
答案 0 :(得分:1)
使用此查询
create view tblResult
select
tblEmployee.EMP_ID, tblEmployee.EMP_NAME, tblEmployee.EMP_MAIL,
tblProjectDetails.EMP_ProjectName, tblProjectDetails.EMP_ProjectDetails
FROM
tblEmployee
INNER JOIN
tblProjectDetails on tblEmployee.EMP_ID = tblProjectDetails.EMP_ID