[code]select getChildrenIdList(1)
获取子集函数代码
[code]CREATE DEFINER=`skip-grants user`@`skip-grants host` FUNCTION `getChildrenIdList`(rootId INT) RETURNS varchar(1000) CHARSET utf8mb4DETERMINISTICBEGINDECLARE sTemp VARCHAR(1000) default rootId;DECLARE sTempChd VARCHAR(1000);SET sTempChd =cast(rootId as CHAR);WHILE sTempChd is not null doif sTemp<>sTempChd thenSET sTemp = concat(sTemp,\',\',sTempChd);END IF;SELECT group_concat(id) INTO sTempChd FROM unify_space_database.t_space where FIND_IN_SET(pid,sTempChd);END WHILE;RETURN sTemp;END