Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select and join

Author  Topic 

sureshsmanian
Starting Member

31 Posts

Posted - 2009-10-19 : 07:03:58
hi
i have two tables
Employee ( Eno - PK, Ename, Deptno - FK refers the Dept table)
Dept (Deptno - PK, Deptname, Mgrno - FK refers the Eno of Employee table)

I need the output in the following way

Eno Ename Mangername
---- ------ ----------

------------------------


Thanks in advance

Regards
SSM

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-19 : 10:39:49
[code]
SELECT Employee.Eno, Employee.EName, Employee_Manager.EName AS ManagerName
FROM Employee

INNER JOIN Dept
ON Employee.DeptNo = Dept.DeptNo

INNER JOIN Employee AS Employee_Manager
ON Dept.MgrNo = Employee_Manager.Eno
[/code]

John
Go to Top of Page

sureshsmanian
Starting Member

31 Posts

Posted - 2009-10-19 : 11:08:06
Thanks a lot. It is working fine
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-10-19 : 15:14:14
My pleasure. Welcome aboard.

John
It's a small world (but I wouldn't want to paint it)
Go to Top of Page
   

- Advertisement -