mysql 如何获取其及其所有子孙的数据或id

/* 通过组织机构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;

  mysql 如何获取其及其所有子孙的数据或id

/* 通过组织机构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;

  mysql 如何获取其及其所有子孙的数据或id

上一篇:Mysql:简单存储过程


下一篇:SAP Spartacus B2B页面Banner Component的路由url是在哪里定义的