问题描述
我有两个表,分别为Users和TimeEntry:
UserID用户名ReporteeID ID EmpCode
1公羊3 111
2 Shyam 3112
3卡兰4113
4亚历克斯4114
这是用户表,其中ReporteeId引用
的UserID用户正在举报.例如Ram的"ReporteeId"为3,即
Karan用户ID,因此Ram正在向Karan报告.
现在这是TimeEntry表:
TimeEntryrID用户ID持续时间
123 1 12
124 2 14
125 4 12
126 6 17
我需要的结果是:-
用户名EmpCode ReporteeUserName
Ram 111 karan
Shyam 112 Karan
亚历克斯114 ALex
分别显示两个表中都存在的用户名,EmpCode和ReporteeUserName
即在用户和TimeEntry表上.
如果可能,请向我发送查询.
I have two tables as Users and TimeEntry:
UserIDUserNameReporteeIDEmpCode
1Ram3111
2Shyam3112
3Karan4113
4Alex4114
This is users table where ReporteeId refer the UserID to whom the
user is reporting.For example Ram''s "ReporteeId" is 3 i.e.
Karan UserID so Ram is Reporting to Karan.
Now this is TimeEntry table:
TimeEntryrID UserIDDuration
123112
124214
125412
126617
I Need the Result as :-
UserNameEmpCodeReporteeUserName
Ram111karan
Shyam112Karan
Alex114ALex
Dispaly the username,EmpCode and ReporteeUserName which exist on both table only
i.e on Users and TimeEntry Table.
Please Send me the query if possible.
这篇关于需要使用联接查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!