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.
| Author |
Topic |
|
balagangadharan
Starting Member
5 Posts |
Posted - 2008-08-08 : 06:26:36
|
Hello Allim developing an application using VS2005(C#)i have Database (SQL 2005) and i have table like thisRid IntroID1 12 13 14 25 26 27 38 39 310 411 412 5 These are the two fields in my table Now in want to get the Rid by passing the IntroID Here is the Query for this Select rid from tbl_tree where IntroID= 1 This query returns three rows. I need query that returns the child datas When I pass Introid as 1, the query returns first three rows as234 Now the query should return the datas for Introid 2,3,4 like wise for all How can I do this?Please help meThanks in Advance![]() |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-08 : 06:29:52
|
quote: I need query that returns the child datas
What is child datas ?quote: When I pass Introid as 1, the query returns first three rows as234
How did the 2, 3, 4 comes from ? From the provided sample data, for IntroID = 1, the RID is 1, 2, 3 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
balagangadharan
Starting Member
5 Posts |
Posted - 2008-08-08 : 06:41:01
|
| Hi Thanks For ReplyingRID INTROID1 12 13 14 25 26 37 3These are the data's i have in my tableThe Query i used to select RID from Table where INTROID =1 isSelect rid from tbl_tree where IntroID= 1so it returns three rows asRID123Now Upline for 2 and 3 is 1downline for 2 is are 4 and 5downline for 2 is are 6 and 7so INTROID 1 is master for 2,3,4,5,6,7so when i pass INTROID as 1, it should return total count for downline as 6return total count for upline as 0so when i pass INTROID as 2, it should return total count for downline as 2return total count for upline as 1like wise for allhow to do this please help meThanks in AdvacnceReagardsBalagangadharan |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-08 : 06:48:15
|
search for Tree & Hierarchy in the sitealso search for recursive CTE as you are using SQL 2005 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|