can someone give me the select query for australian 1 up plan?
explanation of australian 1 up plan:
say company the company is node “zero”
say “one” is the root affiliate to join a company.(under “zero”)
“two” “three” “four” joins under “one”(i,e with referal id of “one”)
again in simailar manner
“five” “six” “seven” joins under “two”
“eight” “nine” “ten” joins under “three” and
“eleven” “twelve” “thirteen” joins under “four”
hope the diagram is clear in your mind till now (or plz draw it on a paper)
now the plan is every second member who joins under “one” becomes his downline.(here “three” and “four” are downlines of “one”(“two” is not “one’s” downline cz “one” is passing “two” for his successor root “zero”)
not only “three” and “four” are the downline of “one” but also every first member who joins under “three” or “four” (i,e under downline of “one”) are also the downlines of “one”
(i,e “eight and “eleven” are also downline of “one”)
(“five” “six” seven” are not downlines of “one” cz they are not the downline of downline of “one” i means they have joined under “two” who is not a downline of “one” thats why they are not in the tree)
one
|
----------------------------------------------------
| | |
two three four
| | |
---------------------- --------------------- ---------------------
| | | | | | | | |
five six seven eight nine ten eleven twelve thirteen
so if my table has two columns as “user_id” (primary key)
and “referal id” as (which pints to the id under which this new user id is created)
then what will be the select query to find all the downlines of “one”
i will be really greatfull to get the answer.
if oracle you can use connect by clause :
for turkish : oracle connect by
for english : oracle connect by
Result :
Result :
hierarchical data in mysql :
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/