我们都知道,在MySQL创建函数的时候,是不能返回table类型的数据的。我有几个疑问:1、在function中我首先创建一个临时表:create temporary table table_tmp (id int,name varchar(20));然后再对table_tmp进行赋值:select id ,name into table_tmp from user;这里会报错,说table_tmp没有声明。2、既然上面说table_tmp没有声明,那么我首先声明一个table:declare table_tmp table(id int,name varchar(20));这里也会报错,说不能这样声明变量,那么是不是在function中不能声明表类型的变量呢?现在唯一的解决办法就是:create temporary table table_tmp select id,name from user;//但是这里不能添加自己的列有没有人能帮我解决下:①MySQL的函数中怎么声明一个table;②在MySQL的函数中怎么创建临时表;谢谢!
添加回答
举报
0/150
提交
取消