时间:2021-07-01 10:21:17 帮助过:8人阅读
BEGIN
DECLARE sTemp text;
DECLARE sTempChd text;
SET sTemp = ‘$‘;
SET sTempChd =cast(rootId as CHAR);
WHILE sTempChd is not null DO
SET sTemp = concat(sTemp,‘,‘,sTempChd);
SELECT group_concat(deptId) INTO sTempChd FROM ch_class where FIND_IN_SET(deptParId,sTempChd)>0;
END WHILE;
RETURN sTemp;
END
select * from ch_class where FIND_IN_SET(deptId,getParLst((SELECT MIN(id) from ch_class where kdgId = 机构ID))) GROUP BY deptParId;
Mysql 通过父节点ID获取所有子节点数据函数
标签:cat declare rom into mysq concat null where group