Procedures are control blocks created in the database in order to optimize a function that will be used at various times, they work so similar to the methods in programming. In MySQL, procedures are used to facilitate routine transaction with the bank and also to help in the process of data manipulation when working with desktop or web interfaces.

To create a procedure in MySQL is necessary to use some commands that together enable its inception, the syntax is as follows:

CREATE PROCEDURE ‘[procedure name]’ ([Parameters])




As a practical example we will perform a SELECT with filters from a variable informed user.

CREATE PROCEDURE ‘sp_product’ (IN _id INT)


Select *

From products

Where id_product = _id


Note that before the variable declaration syntax is used IN stating that this variable will be informed by the user, another way to use variables is to use the command OUT where this variable is returned with some value to the user.

To use the procedure established just use the call command and then the procedure name with parameters, if it has.

call sp_product(1)


Understand the workings of MySQL is paramount for projects that want to increase its cost-effective, learn more about the advantages of PHP combined with MySQL on our official site by clicking the link above.

You might also like…

What advantages for a company in adopting a low-code tool?

Let's understand how low-code tools have become a facilitator in the web development process as they...

How to implement A2F using Swivel in a Scriptcase application

I want to start talking about Swivel, Swivel is a provider of authentication solutions who have been...

Comments, tips and interactions inside Scriptcase.

Hello, here are some tips, comments and interactions about database and tools like HTML, CSS, JavaSc...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.