mercredi 24 décembre 2014

Hierarcy Query Mysql


I have a table like this...



==========================================================================
UID || PARENT ID || SPONSOR ID
==========================================================================
1 || 0 || 0
2 || 1 || 1
3 || 1 || 1
4 || 2 || 1
5 || 3 || 2
6 || 0 || 0
7 || 6 || 0
8 || 4 || 1


Lets say i am a user with UID = 1 , now i want to query so i can get all of my nodes inside my network, how to query this table so i can get this result ( i am a user with uid = 1 , want to gets all of nodes on my network )



============================================================================
UID || PARENT ID || SPONSOR
============================================================================
2 || 1 || 1
3 || 1 || 1
4 || 2 || 1
5 || 3 || 2
8 || 4 || 1


How to do that ? anyone here can help me.. :) Thankyou very much





Aucun commentaire:

Enregistrer un commentaire