/* 通过组织机构i数据获取其所有子孙数据*/ WITH RECURSIVE cte AS (SELECT * FROM organization WHERE organization_id = 1 UNION ALL SELECT organization.* FROM organization INNER JOIN cte ON organization.parent_id = cte.organization_id) SELECT * FROM cte;
/* 通过组织机构id获取其所有子孙id*/ WITH RECURSIVE cte AS (SELECT organization_id FROM organization WHERE organization_id = 1 UNION ALL SELECT organization.organization_id FROM organization INNER JOIN cte ON organization.parent_id = cte.organization_id) SELECT * FROM cte;