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
 COuld you self join? SOme example maybe?

Author  Topic 

y0zh
Yak Posting Veteran

60 Posts

Posted - 2010-04-23 : 06:55:23
COuld you self join? SOme example maybe?

Sachin.Nand

2937 Posts

Posted - 2010-04-23 : 06:58:03
Yes.
select * from table t1 inner join table t2 on t1.id=t2.id

PBUH
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-23 : 06:58:36
quote:
Originally posted by y0zh

COuld you self join? SOme example maybe?


Read about self-join in SQL Server help file
It has example code


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-23 : 09:06:23
quote:
Originally posted by Idera

Yes.
select * from table t1 inner join table t2 on t1.id=t2.id


I can't imagine ever needing to do it that way.

------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2010-04-23 : 11:33:32
maybe parent id of current key

quote:
Originally posted by DBA in the making

quote:
Originally posted by Idera

Yes.
select * from table t1 inner join table t2 on t1.id=t2.id


I can't imagine ever needing to do it that way.

------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-04-23 : 13:44:05
quote:
I can't imagine ever needing to do it that way.

Yes I know.

I posted it because he wanted an 'example' which I thought is the most simplest one.


PBUH
Go to Top of Page
   

- Advertisement -