zoukankan      html  css  js  c++  java
  • MySQL 获取无限级某级的全路径

    传递参数:文件夹ID

     1 DROP FUNCTION IF EXISTS RecursionFolderFullPath;
     2 
     3 CREATE FUNCTION RecursionFolderFullPath(folderId INT(11)) 
     4 RETURNS VARCHAR(1000)
     5 BEGIN
     6 declare fullPath VARCHAR(1000) default '';
     7 declare parentId INT(11) default '0';
     8 
     9 select concat(folder_name,'/',fullPath),folder_parent_id into fullPath,parentId
    10 from folder 
    11 where folder_id=folderId;
    12 
    13 WHILE parentId > 0 DO
    14 select concat(folder_name,'/',fullPath),folder_parent_id into fullPath,parentId
    15 from folder 
    16 where folder_id=parentId;
    17 END WHILE;
    18 
    19 return fullPath; 
    20 END;

    调用:

     1 select RecursionFolderFullPath(67); 

    结果:

  • 相关阅读:
    [hdu1402]A * B Problem Plus(NTT)
    拦截导弹问题(Noip1999)
    删数问题(Noip1994)
    1217:棋盘问题
    随笔功能测试
    教师派8
    教师派7
    教师派6
    教师派5
    教室派4
  • 原文地址:https://www.cnblogs.com/xcjit/p/4150735.html
Copyright © 2011-2022 走看看