mysql 函数
CREATE DEFINER=`root`@`%` FUNCTION `queryChildren`(dpId BIGINT) RETURNS varchar(4000) CHARSET utf8
BEGIN
DECLARE sTemp VARCHAR(4000);
DECLARE sTempChd VARCHAR(4000);
SET sTemp = '$';
SET sTempChd = cast(dpId as char);
WHILE sTempChd is not NULL DO
SELECT group_concat(user_id) INTO sTempChd FROM app_user_invite where FIND_IN_SET(parent_user_id,sTempChd)>0;
if(sTempChd is null) then
SET sTemp = sTemp;
else
SET sTemp = CONCAT(sTemp,',',sTempChd);
end if;
END WHILE;
return sTemp;
END;