Creating a procedure in mySql with parameters

前端 未结 3 1330
梦如初夏
梦如初夏 2020-12-14 06:04

I am trying to make a stored procedure using mySQL. This procedure will validate a username and a password. I\'m currently running mySQL 5.0.32 so it should be possible to

3条回答
  •  独厮守ぢ
    2020-12-14 06:36

    Its very easy to create procedure in Mysql. Here, in my example I am going to create a procedure which is responsible to fetch all data from student table according to supplied name.

    DELIMITER //
    CREATE PROCEDURE getStudentInfo(IN s_name VARCHAR(64))
    BEGIN
    SELECT * FROM student_database.student s where s.sname = s_name;
    END//
    DELIMITER;
    

    In the above example ,database and table names are student_database and student respectively. Note: Instead of s_name, you can also pass @s_name as global variable.

    How to call procedure? Well! its very easy, simply you can call procedure by hitting this command

    $mysql> CAll getStudentInfo('pass_required_name');
    

提交回复
热议问题