首页 > 解决方案 > SQL 存储过程 OUT 总是返回 Null

问题描述

我正在尝试在 SQL 中创建登录并使用存储过程来捕获登录信息。

即使在 phpmyadmin 上执行存储过程,我的输出参数总是返回 Null,我不知道为什么。

userid是我的 OUT 参数,我收到了电子邮件和密码,其余字段为空字符串。

BEGIN
set @userid = (select id from `user` where `email` = email and `password` = password and statusId = 8);

if @userid is not null
then
    set @statu = 9;
elseif @userid is null
then
    set @statu = 10;
end if;

call loginHistory(@userid, email, @statu, ip4, ip6, deviceType, appVer);

set @userid = userid;
END

谢谢

标签: sqlstored-proceduresphpmyadminmariadb

解决方案


改变

set @userid = userid;

SET userid = @userid;

userid并且@userid是不同的东西。

如果这还不够,请向我们展示声明的其余部分。


推荐阅读