输入banner图图片脚本导航/分类

MySQL创建存储过程

存储过程和函数的区别参考链接:

http://www.cnblogs.com/lengbingshy/archive/2010/02/25/1673476.html

创建存储过程:

DROP PROCEDURE mypro;
CREATE procedure mypro (sid INT,OUT sCount INT)
BEGIN

SELECT COUNT(*) INTO sCount from student where id = sid;
END

执行该存储过程:

CALL mypro(1,@c);
select @c;

创建函数:

DROP FUNCTION myfun;
CREATE FUNCTION myfun (sid INT)
RETURNS int
BEGIN
DECLARE sCount int;
SELECT COUNT(*) INTO sCount from student where id=sid;
RETURN sCount;
END

执行函数:
SELECT myfun(1)

MySQL创建存储过程

标签:bsp   sql   blog   log   com   end   begin   logs   html