Re: Recusrion
Posted in 1995
In your example, let us call the table tree and the first column child
and the second column parent. The select statement would be as follows:
select atree.parent, atree.child, btree.child from tree atree, tree btree
where atree.child = btree.parent
and atree.parent = "USA"
notice the use of table aliases. Although this will only give you a
grandparent, parent, child relationship, the principle can be extended as
follows:
select atree.parent, atree.child,btree.child, ctree.child ....
from tree atree,outer(tree btree, outer(tree ctree .... )).. whereatree.child = btree.parent
and btree.child = ctree.parent
and ...
The outer clause is used here in order to report different length of
trees such as:
World Malta Valletta
World USA California San Jose'
World Monaco
Have fun
Andrew Cilia (Philip Toledo Limited - Malta)