赞
踩
MySQL查询某个子节点的顶级节点(根节点)
SELECT T2.* FROM ( SELECT @r AS _id, ( SELECT @r := parent_id FROM `look_project_process` WHERE id = _id ) AS 2v2, @l := @l + 1 AS lvl FROM ( SELECT @r := 'e718165baece49678359dd945371f93e', @l := 0 ) vars, look_project_process h ) T1 LEFT JOIN look_project_process T2 ON T1._id = T2.id WHERE T2.parent_id IS NULL and T2.id is not null
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。