使用联接查询

编程入门 行业动态 更新时间:2024-10-25 23:33:15
本文介绍了使用联接查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个表,提到的EQDUMP和HRISDetails为:- EQDump表为:-

ECode Ename
1 A
2 B
3 C
4 D
HRISDetails表格为:-
ECode EName managername
1 A E
2 B E
3 C F
4 D F
5 E G
6 F G
我需要一个查询,该查询为我提供了EqDump中的Empname字段,EQDUmp中的Ename字段和HRISDetails中的ManagerEmpID字段. 输出结果应如下所示:-
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:-

ECodeEname
1A
2B
3C
4D
HRISDetails Table as:-
ECodeENamemanagername
1AE
2BE
3CF
4DF
5EG
6FG
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:-
ECodeEnameMCode
1A5
2B5
3C6
4D6
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:(

推荐答案

重复的帖子: 使用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">

更多推荐

使用联接查询

本文发布于:2023-10-23 13:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1520977.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!