数据库
首页 > 数据库> > mysql存储过程实现简单分页。

mysql存储过程实现简单分页。

作者:互联网

CREATE PROCEDURE usp_demo(in page int,in pageSize int,out total int,out totalPage int)

BEGIN
	
	DECLARE m int;
	set m=(page-1)*pageSize;
	SELECT * FROM user LIMIT m,pageSize;
	set total = (SELECT COUNT(*) FROM user);
	set totalPage = CEILING(total*1.0/pageSize);
END


set @total=0;
set @totalPage=0;
CALL usp_demo(2,10,@total,@totalPage);
SELECT @total;
SELECT @totalPage;

标签:存储,set,分页,pageSize,int,totalPage,mysql,total,SELECT
来源: https://blog.csdn.net/qq_41373328/article/details/95386451