码迷,mamicode.com
首页 > 数据库 > 详细

mysql if then

时间:2015-05-26 15:52:54      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

CREATE PROCEDURE userinfo_modify(
	IN id INT
	,IN loginid INT
	,IN levelid INT
	,IN	namestr	VARCHAR(50)
	,IN	tel		VARCHAR(50)
	,IN	account	VARCHAR(50)
)
BEGIN
set @lid=loginid;
set @lvid=levelid;
set @n=namestr;
set @t=tel;
set @a=account;
set @uid=id;
select @eid=IFNULL(loginid,0) from userinfo where loginid=@lid;

if (IFNULL(@eid,0)=0)
Then
Insert into userinfo(loginid,levelid,namestr,tel,account)
	VALUES(@lid,@lvid,@n,@t,@a);
select last_insert_id();
ELSE 
	update userinfo
		SET  loginid	=@lid
					,levelid=@lvid
					,namestr=@n
					,tel		=@t
					,account=@a
		where id=@uid;
END IF;
END

  

mysql if then

标签:

原文地址:http://www.cnblogs.com/gxivwshjj/p/4530629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!