存储过程字符串拼接mysql_mysql存储过程求⼤神(拼接字符
串)
BEGINdeclaretable_nameVARCHAR(100);declarestopFlagint;declaresql1VARCHAR(1000);declarecursor_namecursorforlect
BEGIN
相爱时说的话
declare table_name VARCHAR (100);
declare stopFlag int;
declare sql1 VARCHAR (1000);兔狗属相合吗
declare cursor_name cursor
for lect TABLE_NAME from information_schema.KEY_COLUMN_USAGE where TABLE_NAME like 'test_2014%';
declare CONTINUE HANDLER FOR NOT FOUND t stopFlag=1;
t @sql1='create or replace view test as lect id,name from ';
open cursor_name;
REPEAT
FETCH cursor_name INTO table_name;
begin
t @sql1=CONCAT(@sql1,table_name);
lect @sql1;
好听的女生游戏名字PREPARE step FROM @sql1;
EXECUTE step;
糯米烧卖end;
1979年属什么FETCH cursor_name INTO table_name;
UNTIL stopFlag = 1
END REPEAT;
clo cursor_name;
人五人六END
如上存储过程,实现的是数据库中有多个表名为test_201409、等表格,这些表格结构字段都⼀样,现在⽤游标把它们查
询出来后,根据这些表创建视图,有⼀个拼接的过程不会 求⼤神帮忙看下
拼接后的Sql:
lect id,name
from test_201409
union all lect id,name from
冲破黎明前的黑暗先给80分 好了再给80 求⼤神
地下拳击场已经解决!
展开