SELECT ename,man,(SELECT SUM(t1.pop)
FROM tree t1 START WITH t1.ename = t2.ename
CONNECT BY t1.man = PRIOR t1.ename) population
FROM tree t2 start with t2.man is null connect by prior t2.ename=t2.man;
上面的代码是一个oracle
查询。
如何在mariaDB
中执行类似于上面的分层查询?