0

It is simple to write a sql procedure.

demiliter //
create procedure show_growth()
begin
SELECT * from tb;
end //

I want to add a if statement in the procedure.
Drop it first.

 drop procedure show_growth //

Then create a new one.

create procedure show_growth(in type char(3))
    -> begin
    -> if type = "all" then 
    -> SELECT * from tb;
    -> endif
    -> end //

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'end' at line 6

How to fix it?

Chrᴉz remembers Monica
  • 1,829
  • 1
  • 10
  • 24

1 Answers1

0

endif is not 1 word.

 begin
   if type = "all" then    
    SELECT * from tb;
   end if;
 end
Ed Bangga
  • 12,879
  • 4
  • 16
  • 30