本文介绍了使用联接查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HRISDetails表格为:-
我需要一个查询,该查询为我提供了EqDump中的Empname字段,EQDUmp中的Ename字段和HRISDetails中的ManagerEmpID字段.
输出结果应如下所示:-
请向我提供查询(如果可能的话),因为从事数据库方面工作的人员正在休假,而我只需要在紧急情况下写此即可:(
HRISDetails Table as:-
I need a query which gives me the field Empname from EqDump,Ename from EQDUmp and ManagerEmpID from HRISDetails.
The Out put should be look like this:-
Please provide me the query if possible as the guys who are working on database side is on leave and i only have to write this on urgent basis:(
推荐答案
我有两个表,提到的EQDUMP和HRISDetails为:- EQDump表为:-
ECode | Ename |
1 | A |
2 | B |
3 | C |
4 | D |
ECode | EName | managername |
1 | A | E |
2 | B | E |
3 | C | F |
4 | D | F |
5 | E | G |
6 | F | G |
ECode | Ename | MCode |
1 | A | 5 |
2 | B | 5 |
3 | C | 6 |
4 | D | 6 |
I have two table as mentioned EQDUMP and HRISDetails as:- EQDump table as:-
ECode | Ename |
1 | A |
2 | B |
3 | C |
4 | D |
ECode | EName | managername |
1 | A | E |
2 | B | E |
3 | C | F |
4 | D | F |
5 | E | G |
6 | F | G |
ECode | Ename | MCode |
1 | A | 5 |
2 | B | 5 |
3 | C | 6 |
4 | D | 6 |
重复的帖子: 使用Joins查询从ManagerName中查找MCode [ ^ ] duplicate post: Query to find MCode from the ManagerName using Joins[^]
查询应为- Query should be - SELECT eq.ECode, eq.Ename, hri.ManagerEmpID FROM EQDump as eq INNER JOIN HRISDetails as hri ON eq.ECode = hri.ECode
但是在表中,您没有提到ManagerEmpID列.
But in table you did not mentioned the column ManagerEmpID.
select A.EmployeeName,A.Ecode,B.ECode as ManagerECode from HRISDetails as A inner join HRISDetails as B on A.ImmediateSupervisor=B.EmployeeName where A.Ecode in (Select SUBSTRING(ReporteeUserID,4,8) from EQDump)
<pre lang="SQL">
更多推荐
使用联接查询
发布评论