递归取追顶层
作者:
M_ENG | 来源:发表于
2021-04-08 16:56 被阅读0次CREATE DEFINER=`root`@`%` FUNCTION `GET_FIRST_PARENT_ID`(id VARCHAR(50)) RETURNS varchar(10000) CHARSET utf8mb4
SQL SECURITY INVOKER
BEGIN
DECLARE r VARCHAR(10000) default '';
DECLARE tmp VARCHAR(10000) default '';
WHILE tmp != '0' DO
set r = (SELECT region_frame_parent_id FROM hz_region_frame where region_frame_id = id);
IF r != '0' THEN
set id = r;
set tmp = r;
ELSE
set tmp = r;
SET r = id;
END IF;
END WHILE;
RETURN r;
END
本文标题:递归取追顶层
本文链接:https://www.haomeiwen.com/subject/stevkltx.html
网友评论