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
 Self join

Author  Topic 

vijaydaniel.j
Starting Member

2 Posts

Posted - 2009-11-11 : 01:04:32
Hi all..

I would like to have a self join for the table..

intRecID intTopicID vchData
2 0 3B
3 0 4A
4 0 4B
5 2 Belongs to 3B
6 2 Belongs to 3B
7 3 Belongs to 4A
8 3 Belongs to 4A
9 3 Belongs to 4B
10 3 Belongs to 4B

From the above table i would like to have the output as..

vchData1 vchData2
3B Belongs to 3B
3B Belongs to 3B
4A Belongs to 4A
4A Belongs to 4A
4B Belongs to 4B
4B Belongs to 4B

I tried Self joining the table but i couldnt get the above output..
Please help..

Thanks in advance..

Regards.,

Vijay

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-11 : 01:07:59
[code]
select a.vchData, b.vchData
from table1 a
inner join table1 b on a.intRecID = b.intTopicID
[/code]


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

Go to Top of Page

vijaydaniel.j
Starting Member

2 Posts

Posted - 2009-11-11 : 03:25:14
quote:
Originally posted by khtan


select a.vchData, b.vchData
from table1 a
inner join table1 b on a.intRecID = b.intTopicID



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





great.. it worked.. thanks a lot
Go to Top of Page
   

- Advertisement -