ITeye博客

循环遍历函数

Tom_Tomcat · 2016-01-07 20:48 · mysql自定义函数 · 数据库 · Markdown


 

 

 

 

 

 

BEGIN

#Routine body goes here...

DECLARE sTemp VARCHAR(1000);

       DECLARE sTempChd VARCHAR(1000);

       SET sTemp = '0';

       SET sTempChd =cast(currentSys as CHAR);

 

       WHILE sTempChd is not null DO

         SET sTemp = concat(sTemp,',',sTempChd);

         SELECT group_concat(d.menuid) INTO sTempChd FROM

(

select b.menuid,b.menupid,b.url,b.name,b.state,b.sequence,b.isleaf,b.icon,b.lvl from

(select distinct t.menuid from w_manager_rolemenu t where roleid in(

select distinct roleid from h_manager_role_group_detail where group_id in (select groupid from h_manager_user_role_group where account = account))

) a left join w_manager_menu b on a.menuid = b.menuid where b.state  = '1' order by b.lvl,b.sequence

) d  where FIND_IN_SET(d.menupid,sTempChd)>0;

       END WHILE;

RETURN sTemp;

END

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。