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
 Join 2 colums with in the same table

Author  Topic 

normannen
Starting Member

4 Posts

Posted - 2011-11-01 : 22:03:11
Hi.
I need some help, please.
I need to show each person and their boss in one query.
But, can I join to columns with in the same table.
And how do I do that ?
I need a SQL example if anyone can write one.

Thanks in advance.
Please, see example table below.
http://bildr.no/view/1015665

This is a personal project of mine, no school project...

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-11-01 : 22:14:12
something like . ..

SELECT ...
FROM person p1
INNER JOIN person p2 ON p1.boss_id = p2.person_id



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

normannen
Starting Member

4 Posts

Posted - 2011-11-02 : 00:48:18
Thanks.
I'll try that...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-02 : 04:39:08
quote:
Originally posted by normannen

Thanks.
I'll try that...


Hope its always immediate boss you want and not entire hierarchy for an employee

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -