What are stored procedures?
A stored procedure is a set of statements or commands which reside in the database. The stored procedure is precompiled. Each Database has it's own stored procedure language,
Learn how to create Stored Procedure in MySQL at Stored Procedures and Functions in MySQL tutorial page.