Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selection on relations
Message
 
 
To
18/04/2001 09:10:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00496617
Message ID:
00496640
Views:
9
>Hello,
>
>I have a table that keeps information in a kind of sub-records of other records in the same table.
>Each record has an IDKey and a RelationKey. In the RelationKey the number of the parent record (in the same table!) is stored, if the RelationKey = 0 the record indicates a parent node without having other parents above. (I hope I have successfully explained this!)
>
>So the data could look like:
>

>IDKey RelationKey Success
> 1 0 Y
> 2 1 N
> 3 1 Y
> 4 2 y
> 5 4 Y
>

>Now I need to select all records that have the field "Success" = "Y", but ONLY those where also ALL parents have Success = "Y".
>
>I would like to make an inner join or so, but the problem is that I don't know how many subrecords will be there. In this case, record 5 should not be selected, although record 4 (the parent of 5) is set to "Y", because record 2 (the parent of 4) is set to "N".
>How can I solve this problem?

I do not think there is a solution to this because you can have an unlimited recursion up the parent tree. If you changed the success to Y for IDKey 2 and N for IDKey 1, you still would not select record 5. If you were only going back 1 level [the parent and no grandparents], this would be fairly easy.
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform