mysql代码
表:t_b_dr_assets_catalog ,业务字段:parent为表中的上级id字段,2c9081c27337beb501733b876cbf0350 为主键id
【
1、把 t_b_dr_assets_catalog换成自己的业务表
2、parent换成自己业务表的上级id字段
3、2c9081c27337beb501733b876cbf0350 要查询的子id数据
】
select t2.* from( select @r as _id, (select @r := parent from t_b_dr_assets_catalog where id = _id) as parent_id, @I := @I + 1 as lvl from (select @r :='2c9081c27337beb501733b876cbf0350',@I := 0) vars, t_b_dr_assets_catalog h ) t1 join t_b_dr_assets_catalog t2 on t1._id = t2.id ORDER BY id ;
结果:
。
标签:assets,parent,catalog,mysql,父类,dr,id,select From: https://www.cnblogs.com/spll/p/17114521.html