标签:
select id from oc_groups where FIND_IN_SET(id, getChildLst(23));
select id from oc_groups where FIND_IN_SET(id, getChildLst(9))
CREATE FUNCTION `getChildLst`(rootId INT)
RETURNS varchar(1000)
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 oc_groups where FIND_IN_SET(parentid,sTempChd)>0;
END WHILE;
RETURN sTemp;
END
show function STATUS
drop function getChildLst
delete from oc_groups where id>9
标签:
原文地址:http://www.cnblogs.com/a963383404/p/5353289.html