use BASE1 delimiter create function doLand varchar 26 returns varchar

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use BASE1;
delimiter $$;
create function doLand(s varchar(26))
returns varchar(26)
begin
declare sub varchar(26)
drop table if exists tmp
create temporary table tmp (name varchar(26))
while length(s) != 0 begin
set sub = substring_index(s, '/', 1)
insert into tmp (name) values (sub)
s = trim(leading sub from s)
s = trim(leading '/' from s)
end
return select group_concat(name separator '/') from tmp group by ''
end$$
delimiter ;