mysql表名作为参数传入存储过程
程序员文章站
2023-08-26 18:20:43
有以下存储过程: 有这个表: 调用存储过程: 结果: ......
有以下存储过程:
create definer=`root`@`localhost` procedure `p_hovertreepages`( in `tablename` varchar(200), in `fieldlist` varchar(2000) , in `primarykey` varchar(100), in `where` varchar(2000), in `order` varchar(1000), in `sorttype` int, in `recordercount` int, in `pagesize` int, in `pageindex` int, out `totalcount` int, out `totalpagecount` int ) language sql not deterministic contains sql sql security definer comment 'fenye' begin set @sqlstr = concat('select * from ',tablename); prepare sqlstr from @sqlstr; execute sqlstr; end
有这个表:
调用存储过程:
call `p_hovertreepages`('t_hovertreenote', 'h', 'h', 'h', 'h', '1', '1', '2', '1', @hh, @yy)
结果:
上一篇: redis学习(四)redis事务