MySQL 查询所有子级函数

BEGIN
  DECLARE sChildList VARCHAR(4000);
  DECLARE sChildTemp VARCHAR(4000);
  SET sChildTemp =cast(rootId as CHAR);
  WHILE sChildTemp is not null
  DO
    IF (sChildList is not null) THEN
      SET sChildList = concat(sChildList,',',sChildTemp);
    ELSE
      SET sChildList = concat(sChildTemp);
    END IF;
    SELECT group_concat(id) INTO sChildTemp FROM xx_area WHERE FIND_IN_SET(parent, sChildTemp) > 0;
  END WHILE;
  RETURN sChildList;
END

select getAreaAllChildList(651) areaIds

上一篇:POJ.2299 Ultra-QuickSort (线段树 单点更新 区间求和 逆序对 离散化)


下一篇:TP5 数组分页