日期:2014-05-16 浏览次数:20837 次
?
?
DROP FUNCTION IF EXISTS `getChildLst`;
?
CREATE DEFINER = `root`@`%` FUNCTION `getChildLst`(rootId INT)
?RETURNS varchar(1000)
BEGIN?
DECLARE sTemp VARCHAR(3000);
DECLARE sTempChd VARCHAR(3000);
SET sTemp = "-1";
SET sTempChd =cast(rootId as CHAR);
WHILE sTempChd is not null DO
SET sTemp = concat(sTemp,',',sTempChd);
SELECT GROUP_CONCAT(g.groupid) INTO sTempChd FROM wcmgroup g where FIND_IN_SET(g.parentid, sTempChd)>0;
END WHILE;
RETURN sTemp;
END;
?
?
通过rootid遍历rootid一下的所有子节点