In this post, I am going to show you how we can run multiple queries in a single stored procedure in Mysql PhpMyAdmin.

Making stored procedures in PHPMyAdmin (xampp) is very easy just need to do these things.

Steps to create a procedure in PHPMyAdmin:

Step: 1) Click your database, then click More and then click--> Routines.

Step 2:) Click on Add Routine to start a new Procedure.

Step 3:)

  1. Give Routines name means procedure name.
  2. Add parameter in, out, or in_out whichever you want.
  3. In Definition, Write your multiple  SQL queries.
  4. SQL data access: Select Contains SQL.
Step 4:)  At last click on Go. Your procedure is created.


For Example:
Creating a Procedure in phpAdmin.

Creating a simple procedure that selects all Employee Details. 
Procedure Successful Created.

This is a simple way to create a procedure in PhpAdmin.

You can also create a procedure using IN parameter.

Creating a procedure using IN and OUT parameters.
Creating a procedure which returns you id after inserting a row in PhpAdmin.


If you want to write or create procedure manually in Mysql PHPMyAdmin used this syntax: Go to SQL and create a procedure manually.
DELIMITER $$

CREATE PROCEDURE getEmployeeDetails()
BEGIN
SELECT * FROM employee;

END;;
Change accordingly to your procedure.
If you want to write a procedure which insert a record and returns you an ID.
DELIMITER $$
CREATE PROCEDURE `testDemo`(IN `in_name` varchar(50), IN `in_address` varchar(200) ,IN `in_email` varchar(50),OUT `out_emp` INT(50)) BEGIN 

INSERT INTO `employee`( `name`, `address`, `email`)
VALUES (in_name,in_address,in_email);

SELECT max(empid) INTO out_emp FROM employee;
end;;
 

Now you able to create a procedure in MYSQL PhpmyAdmin.

Post a Comment

Previous Post Next Post