存储过程和函数的区别参考链接:
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)
时间: 2024-12-26 19:16:37