第一题
\d ,
mysql> create function count_sch()
returns int
begin
declare count1 int;
select count(*) intoo count1 from t;
return count1;
end,
调用函数
mysql> select count_sch();
+-------------+
| count_sch() |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)
第二题
mysql> create procedure avg_sai1(IN nums int,IN jobs varchar(255),OUT asai double) begin
select avg(sai) into asai from emp where deptno=nums and job=jobs;
end*
mysql> call avg_sai1(30,"销售员",@y);
mysql> select @y;
+-------+
| @y |
+-------+
| 14000 |
+-------+