[英]how to get a particular value from table and store in variable in stored procedure
iam trying to store value from database into a variable inside procedure and increment its value by 1. This is what i do: 我试图将数据库中的值存储到过程中的变量中,并将其值增加1。这是我的工作:
CREATE DEFINER=`satish`@`%` PROCEDURE `p_authTeacher`(
IN username VARCHAR(35),
IN pwd VARCHAR(35),
OUT msg INT,
OUT msg1 INT,
OUT msg2 INT
)
BEGIN
select (COUNT(*) > 0) INTO @result from login where User_Name = username and User_Password = md5(pwd);
SET msg = @result;
IF @result = 1 THEN
select (COUNT(*)>0) into @result1 from login where User_Name = username and User_Password = md5(pwd) and Is_New ='F';
if @result1= 1 Then
UPDATE login SET Last_login=now() where User_Name = username and User_Password = md5(pwd);
SET msg1 = @result1;
END IF;
if @result1= 0 Then
UPDATE login SET Last_login=now() where User_Name = username and User_Password = md5(pwd);
SET msg1 = @result1;
END IF;
END IF;
IF @result = 0 THEN
select Password_Attempts into @attempts from login where User_Name = username ;
SET msg2 = @attempts;
update login set Password_Attempts=1 where username = uname;
END IF;
END
trying to store value of column(Password_Attempts) where username = uname of login table. 尝试存储column(Password_Attempts)的值,其中username =登录表的名称相同。 add 1 into it and update into database.
在其中添加1并更新到数据库。 But certainly i got Syntax error.
但是,当然我有语法错误。 Please help me on this.
请帮我。 the last if block is not working even if the Username and password doesn't match.
即使用户名和密码不匹配,最后一个if块也不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.