<!--递归查询菜单所有子节点-->
<select id="findByChildAllById" resultType="com.erp4cloud.rerp.admin.api.entity.SysMenu">
WITH RECURSIVE cte as
( SELECT m.menu_id,m.name, m.parent_id from sys_menu m where m.menu_id=#{menuId}
UNION ALL
SELECT p.menu_id,p.name,p.parent_id from sys_menu p INNER JOIN cte c on c. menu_id = p.parent_id
)SELECT menu_id ,name , parent_id FROM cte
</select>
<!--递归查询菜单所有子节点-->
<select id="findByChildAllById" resultType="com.erp4cloud.rerp.admin.api.entity.SysMenu">
WITH RECURSIVE cte as
( SELECT m.需要查询的字段名 from tableName m where m.id=#{id}
UNION ALL
SELECT p.需要查询的字段名 from tableName p INNER JOIN cte c on c. id = p.父id
)SELECT 需要查询的字段名 FROM ctem.
</select>