#返回公司的员工个数(无参返回) create function myf1() returns int begin declare c int default 0 #定义变量 select count(*) into c #赋值 from employees; return c; end $
#根据员工名返回他的工资(有参返回) create function myf2(cmpName varchar(20)) return double begin set @sal=0; select salary into @sal from employees where last_name = empName; return @sal; end $
|