首页 > 技术文章 > sql with as 的使用

qq1069284034 2020-02-18 15:33 原文

递归无限级分类查询:

with recursive t as(
select ancestor_org_id,descendant_org_id from v2_organization_tree where ancestor_org_id=215977
union all select k.ancestor_org_id,k.descendant_org_id from v2_organization_tree k,t where t.descendant_org_id=k.ancestor_org_id
) select * from t;

 

https://blog.csdn.net/pg_hgdb/article/details/80307690

推荐阅读