DROP PROCEDURE IF EXISTS db_test.proc_test;
create PROCEDURE proc_test()
BEGIN
declare b varchar(500);
declare sqls varchar(1000);
set b='123;234;567;789';
DROP table IF EXISTS splittable;
CREATE TEMPORARY TABLE splittable(
id INT AUTO_INCREMENT primary key,
VALUE VARCHAR(20)
);
set sqls=concat("insert into splittable(value) values ('",replace(b,';',"'),('"),"')");
select sqls;
SET @sql=sqls; #必须这样转一样
prepare stem from @sql;
execute stem;
DEALLOCATE PREPARE stem;
select * from splittable;
end;