paint-brush
Create and Execute Stored Procedure in PHPMyAdminby@nishit
23,326 reads
23,326 reads

Create and Execute Stored Procedure in PHPMyAdmin

by NishitJanuary 4th, 2020
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

A stored procedure is a prepared SQL code that you can save so the code can be reused over and over again. You can pass parameters to the stored procedure to get data based on Dynamic values. In the Next article I will explain how to Execute Stored Procedure In Laravel Framework. In the next article I’ll also give you a look at the next step in how to execute Stored Procedures using PHP My Admin. In that article I'll explain how you can Execute

Company Mentioned

Mention Thumbnail
featured image - Create and Execute Stored Procedure in PHPMyAdmin
Nishit HackerNoon profile picture

First of all what is Stored Procedure?

A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.

You can pass parameters to the stored procedure to get data based on Dynamic values.

  • Step 1: Open PHP My Admin and select the database to create stored procedure
  • Step 2: Go to Routines menu & Click on Add routine.
  • Step 3: By Clicking on Add Routine Link, PHPMyAdmin will open Pop-up.
  • Step 4 : Follow the steps and create stored procedure.Create stored procedure to get data from users table( Without Parameters).

Stored procedure Without Parameters

Without Parameters

CREATE PROCEDURE `GerUsers`() NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER BEGIN Select * From users; END

Stored Procedure with Parameters

With Parameters

CREATE PROCEDURE `GetUserByEmail`(IN `uEmail` VARCHAR(255)) NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER BEGIN select * from users where email = uEmail; END

Execute Stored Procedure from PHP MyAdmin

PHP MyAdmin will display list of created Stored Procedures.

List of Stored Procedure

Click on Execute link to Run Specific Stored Procedure.

Procedure without parameters will directly Run Query and list out the data Procedure parameters will open Pop up to add parameters, then Run Procedure and get result data.

That’s it. Hope this article helps you guys to understand how to mange Stored Procedure Using PHP My Admin. In the Next article I will explain how to Execute Stored Procedure In Laravel Framework.