日期:2014-05-16 浏览次数:20667 次
DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`sp_test`$$ CREATE PROCEDURE `test`.`sp_test`(IN table_name varchar(255),IN total int) BEGIN set @stmt = concat('select * from ',table_name,' limit ?'); prepare s1 from @stmt; set @s = total; execute s1 using @s; deallocate prepare s1; END$$ DELIMITER ; 调用: call sp_test('表名',数量);
------解决方案--------------------
顶楼上的,prepare