C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Pls help with a query


Posted Date: 01 Dec 2008      Posted By: Mahima      Member Level: Silver     Points: 1   Responses: 3



Hi,

I have a table like :

EmpID EName ManagerID
1 A NULL
2 B 1
3 C 2
4 D 3
5 E 4
6 F NULL

Here the managerid is linked to empid.I want a result like ths :

EmpID EName ManagerName
1 A NULL
2 B A
3 C B
4 D C
5 E D
6 F NULL

Pls any1 help m with a query?






Responses

Author: Yugi    01 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

Good Morning yar

Here you didn't mentioned second table stucture. However use inner join for this.

like:
select tabname1.*,tabname2.* from tabname1
innner join tabname2 on tabname1.primarykey_field= tabname2.primarykey_field



Author: divya    01 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi
Try this
select t1.empid,t1.ename,t2.ename as mngrname from emp t1 inner join emp t2 on t1.empid=t2.mngrid



Author: greeny_1984    01 Dec 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 1

select a.empid,a.ename,b.managername from table1 a ,table2 b where empid=mangerid

Regards,
Greeny_1984

Rate this Response[Excellent/Good/Poor]
FRESHERS check this link
Need help from me join here



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : SQL server 2008
Previous : sql server
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use