add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table treestructure(name varchar(50), path varchar(100), pos_left int,pos_right int,pos_level int)


insert into treestructure(name, pos_left,pos_right ,pos_level ) values('folder1', 207, 214, 1);
insert into treestructure(name, pos_left,pos_right ,pos_level ) values('file1', 208, 209, 2);
insert into treestructure(name, pos_left,pos_right ,pos_level ) values('file2', 210, 211, 2);
insert into treestructure(name, pos_left,pos_right ,pos_level ) values('file3', 212, 213, 2);
update treestructure t
left join treestructure ts on ts.pos_level=t.pos_level-1 and t.pos_left between ts.pos_left and ts.pos_right and t.pos_right between ts.pos_left and ts.pos_right
set t.path=(case when t.pos_level=1 then t.name else concat(ts.name,'/',t.name) end);

select*from treestructure
name path pos_left pos_right pos_level
folder1 folder1 207 214 1
file1 folder1/file1 208 209 2
file2 folder1/file2 210 211 2
file3 folder1/file3 212 213 2