MySql 函数

CREATE FUNCTION `getCatalogChildIds`(rootId BIGINT) RETURNS char(255) CHARSET utf8
BEGIN
DECLARE str char(255) ;
DECLARE cid char(255) ;

SET str = '';
SET cid =cast(rootId as CHAR);

WHILE cid is not null DO
SET str= concat(str,',',cid);
SELECT group_concat(id) INTO cid FROM db_pop_asset_classification where FIND_IN_SET(pId,cid)>0;
END WHILE;
RETURN str;
END