drop procedure if exists mlook;
create procedure mlook(in tbl varchar(100))
begin
IF NOT EXISTS (SELECT * FROM information_schema.columns
WHERE table_schema='mes' AND table_name = @name AND column_name = 'data_src') THEN
SET @sqlcmd = concat('select * from ', tbl);
prepare stmt from @sqlcmd;
execute stmt;
deallocate prepare stmt;
ELSEIF EXISTS (SELECT * FROM information_schema.columns
WHERE table_schema='mes' AND table_name = @name AND column_name = 'data_src') THEN
SET @sqlcmd = concat('select * from ', tbl,'WHERE data_src=U8');
prepare stmt from @sqlcmd;
execute stmt;
deallocate prepare stmt;
END if;
end;
call mlook('mi_inventory');
希望能帮助到各位。
mysql 存储过程动态传表名,删除表数据
最新推荐文章于 2022-02-15 11:32:26 发布