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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Parent and Child table datas in a single table

Author  Topic 

vijayanto
Starting Member

16 Posts

Posted - 2009-06-23 : 06:11:23
hi friends,
i have trouble while making sql query
i have created table with two fields that is Father field and Child field but in the Child field may have another Child datas


so i want to display the datas in father with child datas and also must display the child datas for the Child field

please give me a solution
regards
vijay

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-06-23 : 06:32:47
Will you update your table structure and expected result?


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-23 : 06:52:27
Read the excellent Microsoft SQL Server help file, called Books Online, for "recursive CTE".



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-06-23 : 07:04:44
Or (depending on requirements) create a simple self join...?
SELECT * 
FROM table1 father
INNER JOIN table1 child
on child.FatherID = father.ID
WHERE father.FatherID IS NULL


- Lumbago
Go to Top of Page
   

- Advertisement -