0
点赞
收藏
分享

微信扫一扫

MySql 递归父级查询所有子级

窗外路过了谁 2022-03-18 阅读 59
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 条评论