我們都知道,在MySQL創(chuàng)建函數(shù)的時候,是不能返回table類型的數(shù)據(jù)的。我有幾個疑問:1、在function中我首先創(chuàng)建一個臨時表: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中不能聲明表類型的變量呢?現(xiàn)在唯一的解決辦法就是:create temporary table table_tmp select id,name from user;//但是這里不能添加自己的列有沒有人能幫我解決下:①MySQL的函數(shù)中怎么聲明一個table;②在MySQL的函數(shù)中怎么創(chuàng)建臨時表;謝謝!
添加回答
舉報
0/150
提交
取消