mySql存储过程中出现空白错误

时间:2021-12-25 15:37:50

I am trying to write a simple login stored procedure in mySql for simple testing purposes. I am stumped as to why it errors out. Here is my code:

我试图在mySql中编写一个简单的登录存储过程,以便进行简单的测试。我很难过为什么会出错。这是我的代码:

create procedure prLogin (IN userID varchar(20), IN pw varchar(20))

begin

select * from userlogin 
inner join users on userlogin.id = users.userid 
where userlogin.username = userID and userlogin.password = pw;

end

As I mentioned above, this code fails, but offers no clue as to why. Can anyone help me? Thanks! Viv

正如我上面提到的,这段代码失败了,但没有提供任何关于原因的线索。谁能帮我?谢谢! VIV

1 个解决方案

#1


0  

The only thing I can find is that you have not change your delimiter, If you don't change it, the whole statement will break at the last ; which happens on line a.password = pw;.

我唯一能找到的就是你没有改变你的分隔符,如果你不改变它,那么整个语句最后都会破坏;这发生在线a.password = pw;。

DELIMITER $$
CREATE PROCEDURE prLogin (IN userID varchar(20), IN pw varchar(20))
BEGIN
    SELECT  a.*, b.*
    FROM    userlogin a
            INNER JOIN users b
                ON a.id = b.userid 
    WHERE   a.username = userID AND 
            a.password = pw;
END $$
DELIMITER ;

by changing the character of delimiter (anything you want and my chosen chars are $$), the statement will stop on the new character and not on ;.

通过更改分隔符的字符(任何你想要的和我选择的字符是$$),语句将停止在新字符上,而不是在;

#1


0  

The only thing I can find is that you have not change your delimiter, If you don't change it, the whole statement will break at the last ; which happens on line a.password = pw;.

我唯一能找到的就是你没有改变你的分隔符,如果你不改变它,那么整个语句最后都会破坏;这发生在线a.password = pw;。

DELIMITER $$
CREATE PROCEDURE prLogin (IN userID varchar(20), IN pw varchar(20))
BEGIN
    SELECT  a.*, b.*
    FROM    userlogin a
            INNER JOIN users b
                ON a.id = b.userid 
    WHERE   a.username = userID AND 
            a.password = pw;
END $$
DELIMITER ;

by changing the character of delimiter (anything you want and my chosen chars are $$), the statement will stop on the new character and not on ;.

通过更改分隔符的字符(任何你想要的和我选择的字符是$$),语句将停止在新字符上,而不是在;