Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query help: with root, find all child nodes
Message
From
05/12/2004 12:50:23
 
 
To
05/12/2004 01:41:09
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00966953
Message ID:
00966992
Views:
15
Hi Alvin.

What I am trying to accomplish is to write a query that will be supplied a root value.. ie A and I want to find the downlines..

What would make this process much easier is to implement a "rip field" and update it using a trigger. This is what I mean by a rip field is a field that concatenates the PK's of all the ancestor node for a given node. In your example, these would be the rip fields:

A - A*
B - A*B*
C - A*C*
D - A*B*D*
E - A*B*E*
F - A*B*D*F*
J - A*C*J*
H - A*C*H*
G - A*B*E*G*

Then, to get the downline for any given node, let's use node C as an example here, you query just looks like this:

SELECT * FROM nodes WHERE ripfield LIKE 'A*C*%'

Is this what you are looking for?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform