Mysql How to sort row ORDER BY other row of record?

A

Anonymous

Guest
My database tbl_user has the following columns :
4vqqxc20ldr81.jpg


$user_id = 2;
$user_tree = $this->getAllRec("u.user_id",
"tbl_user u",
"WHERE u.Upline = '".$user_id."'
ORDER BY Right_id ASC");
print_r($user_tree);

Now the sequence it output (user_id 6) first then only output (user_id 5)

I want the array `$user_tree` to hold (user_id 5) first, then (user_id 6), how to do that?

I want to print (Left_id) first, then only print (Right_id). May I know how to do it?
 
If I understood you correctly, you can add sorting on second column like
Code:
ORDER BY upline DESC, Right_id ASC
 
Back
Top