|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hai.
i have problem in sql. i have a table with 2 field which is memberid and uplineid. let say steven is in highest level manager. i want to select his downline and his can view his downline's downline. (mean can drill down to many level down.) how i going to write the sql statement??? the problem is i dunno they have how many level.. somebody can help me??? i feel helpless.... |
|
#2
|
|||
|
|||
|
Give us a little more detail please. I am sure we can give you some help, but just need a little more info on what you are trying to do. Thanks
|
|
#3
|
|||
|
|||
|
I have the same problem... here's a little more info:
I have a table of users called (surprise) Users, which amongst other columns, has an ID column. I have a linking table called User_Uplines, which contains the foreign keys FK_UserID (which points to the Users.ID column of the User), and FK_UplineID (which points to the Users.ID column of the User's Upline Sponsor). So, the query: Select * from User_Uplines where FK_UplineID = @UserID will return all of a user's FIRST LEVEL subordinates. The problem is, I'd like to return ALL of the User's downlines' downlines, traversing every branch, until there are no more. I could certainly do this with a (rather nasty) cursor, or bring the recursive function into C# and make a BUNCH of db calls to get the first level of each user, and recursive through a collection until I reach the last entry. BUT, is there any way to write a recursive routine in SQL that would do this? Many thanks in advance, and if you need any more info, please let me know. Thanks, Bill |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > urgent |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|