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;
mysql存储过程实现简单分页。
最新推荐文章于 2024-05-06 16:41:35 发布