示例1:
调用语句call agm('a3 desc',0,5)
CREATE PROCEDURE `agm`(IN order_param varchar(10),IN anchor int,IN size int)
BEGIN
set @s = concat("select * from test1 order by ",order_param," limit ",anchor,",",size);
prepare stmt from @s;
execute stmt;
DEALLOCATE prepare stmt;
END
示例2:
调用语句call agm1('a3 desc',0,5)
CREATE PROCEDURE `agm1`(IN order_param varchar(10),IN anchor int,IN size int)
BEGIN
set @s = "select * from ag_tag order by ? limit ?,?";
prepare stmt from @s;
set @a=order_param;
set @b=anchor;
set @c=size;
execute stmt USING @a,@b,@c;
DEALLOCATE prepare stmt;
END