MySql 递归父级查询所有子级
select t3.subject_code,t3.psubject_code,t3.id
from
(
select t1.subject_code,t1.psubject_code,t1.id,
if(find_in_set( psubject_code, @pcode ) > 0, @pcode := concat( @pcode, ',', subject_code ), 0 ) as chilCode from
(select f.subject_code,f.psubject_code,f.id from psubject f where f.del_flag=0 ) t1,
( SELECT @pcode := 17010601 ) t2
) t3 where t3.chilCode !=0
仅供参考,希望对您有所帮助,感谢阅读。
注:本文章,是从各大网站、各位道友以及老师等处学习,自己总结做的一些笔记,不对的地方望海涵,如有问题,请及时联系。
共有 0 条评论