Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My table structure is:->

________________________________________
tableName:UserDetail

userid [int identity]

userName [nvarchar(100)]

leftMemberID [int]

rightMemberID [int]

leftCount [int]


__________________________________________________________________
All members added in a binary tree format.

What i have to do is that, how to count left side members under particular user???

Now what's the matter is .. I want a SQL Query which can go under and under.. like 'John Doe' having two members under him named 'Suzan' and 'Ellie' and 'Suzan' is also having 2 members under her.. and same for Ellie. and for example.. 'John Doe' having about 300 members in his down line?
Posted

Simple, use a "SQL Procedure" and use FOR LOOP or WHILE LOOP in that "Procedure"
 
Share this answer
 
Comments
Harpreet_125 21-Jan-14 13:32pm    
can you please tell me how... i am totally new to sql..
you can simply use nested for loop or nested foreach loop !
 
Share this answer
 
Comments
Harpreet_125 21-Jan-14 13:32pm    
can you please tell me how... i am totally new to sql..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900