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.

By ,

August 26, 2013


You might also like…

5 reasons you can’t miss a Black Friday Scriptcase!

This November we bring you the biggest and most important discounts of the year! And do you know wh...

Taking a look at Scriptcase version 9.7

After the big Scriptcase 9.7 presentation event, we have a new version of Scriptcase for download, ...

October Newsletter

Follow the latest news for the month of October! Webinars, blog posts, videos, and more. WEB...

You might also like…

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.