创建mysql函数 fun_Knowledge_child_url, 输入一个int类型节点chId,return一个url字符串
BEGIN DECLARE sTemp VARCHAR(1000); DECLARE sTempChd VARCHAR(1000); DECLARE knoName VARCHAR(100); DECLARE tempPid INT; SET sTemp = ‘$‘; SET knoName = ‘$‘; SET tempPid = chId; SELECT t3.`name` into sTemp FROM mooc_si_knowledge_tree t3 where t3.id = chId; WHILE tempPid>0 DO SELECT t.pId into tempPid FROM mooc_si_knowledge_tree t where t.id = tempPid; IF tempPid>0 THEN SELECT t2.`name` INTO knoName FROM mooc_si_knowledge_tree t2 where t2.id=tempPid; SET sTemp = CONCAT(knoName,‘/‘,sTemp); END IF; END WHILE; RETURN sTemp; END
时间: 2024-10-11 18:10:13