using procedures in mysql code example
Example: MySQL Stored Procedures
DELIMITER $$
CREATE PROCEDURE GetCustomers()
BEGIN
SELECT
customerName,
city,
state,
postalCode,
country
FROM
customers
ORDER BY customerName;
END $$
DELIMITER ;
-- Once you save the stored procedure, you can invoke it by using the CALL statement:
CALL GetCustomers();