1、操作select 语句:
drop function if exists hello;
create function hello(a int) returns varchar (255)
begin
declare x varchar(255);
select `name` into x from gl_dept where id = a;
return x;
end;
其中“select name
into x from gl_dept where id = a;”里面的“into x“,只是一个给字段添加别名的方式,必须添加,而且别名必须是声明过的。
调用方式:
select hello (5);
结果: