【发布时间】:2020-11-10 05:19:48
【问题描述】:
我有一个mysql存储过程来检查登录信息是否与我的数据库信息匹配
obs:我刚开始使用Mysql,所以这段代码可能有很多错误。
-表 1 - 函数 (email_func,senha)
-表 2 - Cliente (email_cli,senha_cli)
这是sp代码
delimiter %%
create procedure SpLogin(email varchar(100), senha varchar(15))
begin
declare c int;
declare f int;
begin
if exists(select * from cliente where email_cli = email and senha_cli = md5(senha))
then select 'c' as result;
else set c = 0;
end if;
end;
begin
if exists (select * from funcionario where email_func = email and senha = senha)
then select 'f' as result;
else set f = 0;
end if;
end;
begin
if (f = 0 and c = 0)
then select '0' as result;
end if;
end;
end %%
delimiter ;
当我用这封电子邮件调用 sp 时,两个表中有一个相同的“电子邮件” 无论我写什么“senha”,它总是返回“f”作为结果。
【问题讨论】:
标签: mysql sql database stored-procedures procedure