Recursive MySQL function -


i need find clan in. link clan through clan leader. linked else pyramid. need loop through members , find top person.

example

tblclan [id][name][owner] [1][my clan][tom] [2][another clan][fred]  tblavatar [name][linkedby] [tom][null] [bel][tom] [nathan][bel] [mya][fred] [fred][null] 

what clan nathan in? find nathan, he's linked bel, find bel, shes linked tom, find tom, tom isnt linked anyone... own clan? yes nathan belongs in clan

currently using recursive php function doing select statements. how in 1 query instead of looping same query?

or task count how many members in clan using similar reversed method.


Comments