C 练习实例35 之mysql实现

题目:字符串反转,如将字符串 "www.runoob.com" 反转为 "moc.boonur.www"。

 

drop PROCEDURE if exists test;
 
create PROCEDURE test (  a varchar(100)    )  
 begin 

	  declare rst varchar(100);
		declare i ,len int;
    set i=1;
		set rst='';
		set len=LENGTH(a);
   
		while i<=len do 
			set rst=CONCAT(SUBSTR(a,i,1),rst);
			set i=i+1;
		end while;

		select rst,reverse(a) as rst2;
end;  

 

你可能感兴趣的:(mysql)