更新时间:2023-02-05 16:21:32
一般语法
DELIMITER $$
CREATE
PROCEDURE `moodle`.`procedureName`(IN id INT, IN NAME VARCHAR(20))
BEGIN
-- paste QUERY here;
SELECT * FROM user WHERE user_name = NAME AND user_id =id;
END$$
DELIMITER ;
这是一个参数化存储过程,其中包含两个 IN
类型参数,名为 id,其 datatype
是 int
其他是 name
其 datatype
是 varchar(20)
,它们作为 user_name = NAME
和 user_name = NAME
在在存储过程中查询.
this is a parametrized stored procedure where which contain two IN
type parameter named as id whose datatype
is int
other is name
whose datatype
is varchar(20)
which are passe as user_name = NAME
and user_name = NAME
in query in the stored procedure.
您可以使用以下查询调用存储过程
you can call stored procedure using following query
call procedureName(1,'test');
@sql
不是存储过程,它是用户定义的变量,因为 var
在下面的情况下
@sql
is not an stored procedure it is user defined variable as var
is in below case
SET @var='testing varible';
SELECT @var;
通过运行上面的查询,您将获得存储在上面变量中的值
by running the query above you will get the value stored in the above variable