sql with as 的使用

递归无限级分类查询:

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

posted on 2020-02-18 15:33  小帅豹  阅读(381)  评论(1编辑  收藏  举报