下面的sntax接縫是正確的。在mysql上運行時出現錯誤如何在MYSQL中編寫嵌套if else
錯誤代碼:1064.您的SQL語法錯誤;檢查對應於你的MySQL服務器版本在第27" 行使用「」附近正確語法手冊。
delimiter $$
create function check2_login(p_username varchar(30),p_password varchar(30),role varchar(20))
returns bool
deterministic
begin
declare loginstatus bool default false;
if role="customer"then
select custid from customer where custid=p_username and pwd=p_password;
if !row_count()=0 then
select true into loginstatus;
end if;
else if role="executive"then
select execid from executive where execid=p_username and pwd=p_password;
if !row_count()=0 then
select true into loginstatus;
end if;
else if role="admin"then
select empid from employee where empid=p_username and pwd=p_password;
if !row_count()=0 then
select true into loginstatus;
end if;
else
return loginstatus;
end if;
return loginstatus;
end $$
打賭你希望你有一個登錄表... –