Harjeet Jadeja Harjeet Jadeja - 22 days ago 5
MySQL Question

how to write procedure to insert data in to the table in phpmyadmin?

I have created table as below:

student:


uid | name | user_name | branch




I want to insert data in to the table using procedure.

the procedure which i wrote is:


create procedure add(in_name varchar(50),in_user_name
varchar(50),in_branch varchar(50))

begin

insert into student
(name,user_name,branch) values (in_name ,in_user_name,in_branch);

end;

Answer

Try this-

CREATE PROCEDURE simpleproc (IN name varchar(50),IN user_name varchar(50),IN branch varchar(50))
BEGIN
    insert into student (name,user_name,branch) values (in_name ,in_user_name,in_branch);
END