General information
Forum:
Microsoft SQL Server
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only