解决方案 »

  1.   

    CREATE FUNCTION topoFolderFun(folderIdTmp bigint(20)) RETURNS varchar(1000) 
    DETERMINISTIC
    begin
    declare sTemp varchar(1000);
    declare sTempChd varchar(1000);
    set sTemp = '';
    set sTempChd = cast(folderIdTmp as char);
    lable : loop 
    set sTemp = concat(sTemp,',',sTempChd);
    select group_concat(folderId) into sTempChd from topofolder where find_in_set(superiorId, sTempChd) > 0;
    if found_rows()=0 or sTempChd is null then
    return substring(sTemp,2);
    end if;
    end loop;
    end$$
      

  2.   

    给你一个关于获得上级地域的fun
      

  3.   

    跟我写的没什么区别 ,只不过是用的loop
    我说的意思是 不写循环 就单独执行一次都不行
    唉 已经找到个方法 直接写sql语句查询能得到结果了 
    不过没弄清楚这个问题 还是很不爽
      

  4.   

    你的那个去掉SET tempChilidId = cast(goodsTypeId as CHAR);
    就可以了
      

  5.   

    去掉了之后直接得到个null
    就是把where后面改成  GoodsTypeID= goodsTypeId 直接用传入的参数 结果也不对 
      

  6.   

       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://bbs.csdn.net/topics/320211382
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。