我试图将数据库中的值存储到变量内部过程中并将其值增加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
尝试存储列(Password_Attempts)的值,其中username = uname of login table。 将1添加到其中并更新到数据库中。但当然我得到了Syntax错误。请帮帮我。即使用户名和密码不匹配,最后一个if块也不起作用。
答案 0 :(得分:1)
有关SELECT ... INTO
的正确语法,请参阅this链接。您应该将INTO
放在FROM
之前:
select Password_Attempts into @attempts from login where User_Name = uname ;