mysql存储过程-汇总学习
简单的存储过程插入语句
BEGIN INSERT into useraccount VALUES (10,10,3,'2013-01-02',9);#RoauDtine body goes here... select ROW_COUNT(); -- 表示影响的行数 END
简单的存储过程ifelse语句(UserId为in,UserName为out)
BEGIN IF UserId = 18 THEN SET UserName = '5'; END IF; IF UserId = 14 THEN SET UserName = '4'; END IF; #Routine body goes here..., END
简单的存储过程ifelse语句(UserId为in,UserName为out),这里遇到的问题是select 返回数量和正常查询的结果不一致,后来改了多个参数,最终确定为userid与表中UserId重复导致,而且大小写也无法区分,所以将其更改为userid1
BEGIN if(username>5) THEN select count(*) from useraccount where UserId>17;#Routine body goes here... ELSE SET userid1=4; end if ; END