验证中...
函数
Raw Copy
CREATE DEFINER=`root`@`localhost` FUNCTION `getChildList`(rootId varchar(50)) RETURNS varchar(1000) CHARSET utf8mb4
READS SQL DATA
BEGIN
DECLARE sTemp VARCHAR(16380);
DECLARE sTempChd VARCHAR(1000);
SET sTemp = '$';
SET sTempChd =cast(rootId as CHAR);
WHILE sTempChd is not null DO
SET sTemp = concat(sTemp,',',sTempChd);
SELECT group_concat(account_number) INTO sTempChd FROM budget_account_info where FIND_IN_SET(sup_account,sTempChd)>0;
END WHILE;
RETURN sTemp;
END
sql
Raw Copy
select account_number,ischild from (
select t1.account_number,
if(find_in_set(sup_account, @pids) > 0, @pids := concat(@pids, ',', account_number), 0) as ischild
from (
select account_number,sup_account from budget_account_info t where t.status = 1 order by account_number,sup_account
) t1,
(select @pids := '5502') t2
) t3 where ischild != 0 order by account_number;

Comment list( 0 )

You need to Sign in for post a comment

Help Search