获取父IDs:
BEGIN DECLARE sTemp VARCHAR(1000); DECLARE sTempPar VARCHAR(1000); SET sTemp = ''; SET sTempPar =childId; WHILE sTempPar is not null DO SET sTemp = concat(sTemp,',',sTempPar); SELECT group_concat(parentid) INTO sTempPar FROM t_runner_menu where parentid<>id and FIND_IN_SET(id,sTempPar)>0; END WHILE; RETURN sTemp; END 参数:childId varchar(50) 回传类型:varchar(1000) CHARSET gbk
获取子IDs:
BEGIN DECLARE sTemp VARCHAR(1000); 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(id) INTO sTempChd FROM t_organization where FIND_IN_SET(parent_id,sTempChd)>0; END WHILE; RETURN sTemp; END 参数:rootId INT 回传类型:varchar(1000) CHARSET gbk
当一个人找不到出路的时候,最好的办法就是将当前能做好的事情做到极致,做到无人能及。