What is a stored procedure in MySQL?

DELIMITER //

CREATE PROCEDURE get_students_by_city(IN city_name VARCHAR(50))
BEGIN
  SELECT * FROM students WHERE city = city_name;
END //

DELIMITER ;

CALL get_students_by_city('Delhi');

A procedure saves code on the server, can take parameters, and can be reused by many programs. DELIMITER is only needed in the command line, so the ; inside the procedure does not end the command too early.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.