//sql调用
SELECT
hierarchy_id
FROM
sys_hierarchy
WHERE
FIND_IN_SET(
hierarchy_id,
queryChildrenAreaInfo ('c1f68483be37115d618fddd1b7dc24c0')
);
//sql函数创建
//p_hierarchy_id 父级id
//hierarchy_id 子级id
CREATE FUNCTION `queryChildrenAreaInfo`(parentId VARCHAR(200)) RETURNS varchar(4000) CHARSET utf8
BEGIN
DECLARE sTemp VARCHAR(4000);
DECLARE sTempChd VARCHAR(4000);
SET sTemp='$';
SET sTempChd = CAST(parentId AS CHAR);
WHILE sTempChd IS NOT NULL DO
SET sTemp= CONCAT(sTemp,',',sTempChd);
SELECT GROUP_CONCAT(hierarchy_id) INTO sTempChd FROM sys_hierarchy WHERE FIND_IN_SET(p_hierarchy_id,sTempChd)>0;
END WHILE;
RETURN sTemp;
END
//sql调用SELECT hierarchy_id FROM sys_hierarchy WHERE FIND_IN_SET( hierarchy_id, queryChildrenAreaInfo ('c1f68483be37115d618fddd1b7dc24c0') );//sql函数创建//p_hie