Get root path of a tree with pure MySQL
问题 I want to get path from node to root of a tree. This is my tree for example: id | name | parent_id ------------------------------ 1 | mike | 0 2 | danny | 1 3 | peter | 1 4 | clark | 2 5 | lily | 1 6 | stefan | 3 7 | simon | 3 8 | boby | 1 9 | john | 4 10 | elly | 4 I write an algoritm with php and mysql but it is slowly public function GetRootPath($a_id) { $root=""; $results=""; while(1==1){ $result = DB::select("SELECT id, parent_id FROM users WHERE id=$a_id"); if($result[0]->refr!=0) { if(