“pr_add” 是个简单的 MySQL 存储过程,这个MySQL 存储过程有两个 int 类型的输入参数 “a”、“b”,返回这两个参数的和。
1. drop procedure if exists pr_add;
2. 计算两个数之和
create procedure pr_add
(
a int,
b int
)
begin
declare c int;
if a is null then
set a = 0;
end if;
if b is null then
set b = 0;
end if;
set c = a + b;
select c as sum;
/*
return c;
不能在 MySQL 存储过程中使用。return 只能出现在函数中。
*/
end;
mysql> DELIMITER //
mysql> CREATE PROCEDURE proc1(OUT s int)
-> BEGIN
-> SELECT COUNT(*) INTO s FROM user;
-> END
-> //
mysql> DELIMITER ;
链接 http://database.51cto.com/art/201006/203159.htm##1
create view stu_class(id,name,glass) as select student.s_id,student.name,stu_idfo.class from student,stu_infowhere student.s_id=stu_info.s_id;
https://blog.csdn.net/wangxingfan316/article/details/78953649