using “if” and “else” Stored Procedures MySQL

前端 未结 3 1604
悲哀的现实
悲哀的现实 2021-01-01 11:52

I\'m having some difficulties when trying to create this stored procedure, any kind of help is welcome:

create procedure checando(in nombrecillo varchar(30),         


        
3条回答
  •  梦谈多话
    2021-01-01 12:23

    The problem is you either haven't closed your if or you need an elseif:

    create procedure checando(
        in nombrecillo varchar(30),
        in contrilla varchar(30), 
        out resultado int)
    begin 
    
        if exists (select * from compas where nombre = nombrecillo and contrasenia = contrilla) then
            set resultado = 0;
        elseif exists (select * from compas where nombre = nombrecillo) then
            set resultado = -1;
        else 
            set resultado = -2;
        end if;
    end;
    

提交回复
热议问题