Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query help: with root, find all child nodes
Message
De
05/12/2004 12:50:23
 
 
À
05/12/2004 01:41:09
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00966953
Message ID:
00966992
Vues:
10
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?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform