In Oracle there is PL/SQL, a powerful imperative language. Is there anything similar for MySQL?
Google for "Getting started with mysql stored procedures", the syntax is not that far from PLSQL.
DELIMITER // CREATE PROCEDURE GetAllProducts() BEGIN SELECT * FROM products; END // DELIMITER ;