mysql分页存储过程一步一步实现
Posted 活灵活现
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql分页存储过程一步一步实现相关的知识,希望对你有一定的参考价值。
1.
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,‘ order by ‘,PrimaryKey,‘ desc limit ?,?‘); prepare sqlStr from @sqlStr ; set @hstart=PageSize*(PageIndex-1); set @hsize=PageSize; execute sqlStr using @hstart,@hsize; END
调用:
CALL `P_HoverTreePages`(‘t_hovertreenote‘, ‘h‘, ‘hid‘, ‘h‘, ‘h‘, ‘1‘, ‘1‘, ‘3‘, ‘1‘, @hh, @yy)
以上是关于mysql分页存储过程一步一步实现的主要内容,如果未能解决你的问题,请参考以下文章