您好,欢迎访问一九零五行业门户网

mysql中实现相仿oracle的SYS_CONNECT_BY_PATH功能

mysql中实现类似oracle的sys_connect_by_path功能 oracle中的sys_connect_by_path函数为开发带来了便利,mysql中如何实现类的功能呢? delimiter $$ create function `getparentlist` (rootid varchar (50)) returns varchar (1000) begin declare sparentlis
mysql中实现类似oracle的sys_connect_by_path功能
   oracle中的sys_connect_by_path函数为开发带来了便利,mysql中如何实现类似的功能呢?
delimiter $$
create function `getparentlist` (rootid varchar (50)) returns varchar (1000) 
begin
  declare sparentlist varchar (1000) ;
  declare sparenttemp varchar(1000); 
  set sparenttemp =cast(rootid as char); 
  while sparenttemp is not null do 
  if (sparentlist is not null) then 
  set sparentlist = concat(sparenttemp,'/',sparentlist); 
  else 
  set sparentlist = concat(sparenttemp); 
  end if; 
select group_concat(parent_module_id) into sparenttemp from top_sys_module where find_in_set(module_id,sparenttemp)>0; 
end while; 
return sparentlist; 
end$$
delimiter ;
select module_id,parent_module_id,getparentlist(module_id) from top_sys_module;
其它类似信息

推荐信息