delimiter //
create procedure pro1(in tabids varchar(22),in tabcolumns varchar(22),in grades varchar(22),in splitflg varchar(22))
begin
declare result varchar(255) default '';
declare cnt int default 0;
declare i int default 0;
set cnt = 1+(length(tabids) - length(replace(tabids,splitflg,'')));
while i
do
set i=i+1;
insert into cs2 (sid,cid,g) values(reverse(substring_index(reverse(substring_index(tabids,splitflg,i)),splitflg,1)),reverse(substring_index(reverse(substring_index(tabcolumns,splitflg,i)),splitflg,1)),reverse(substring_index(reverse(substring_index(grades,splitflg,i)),splitflg,1)));
end while;
end //
delimiter ;
create table cs2(sid varchar(22), cid varchar(22), g varchar(22));
call pro1 ('11,22','33,44','99,45',',');