码迷,mamicode.com
首页 > 数据库 > 详细

mysql分页存储过程一步一步实现

时间:2018-11-10 15:10:57      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:proc   div   RoCE   col   size   esc   create   page   primary   

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分页存储过程一步一步实现

标签:proc   div   RoCE   col   size   esc   create   page   primary   

原文地址:https://www.cnblogs.com/hlhx/p/9938777.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!