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

mysql 分页存储过程

时间:2015-11-17 16:37:40      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

CREATE PROCEDURE sp_GetInfo(
in _where varchar(2000),
in _orderby varcahr(200),
in _pageindex int,
in _pagesize int,
out _totalcount)
BEGIN
  SET @startrow = _pagesize * (_pageindex - 1) ;
  SET @pagesize = _pagesize ;
    set @strsql=select * from feedback;
  SET @strwhere = CONCAT(
    CASE
      IFNULL(_where, ‘‘) 
      WHEN ‘‘
      THEN ‘‘
      ELSE CONCAT( where 1=1 , _where) 
    END,
      CASE
      IFNULL(_orderby, ‘‘) 
      WHEN ‘‘
      THEN ‘‘
      ELSE CONCAT( order by , _orderby) 
    END
  ) ;
    set @sql1=CONCAT(@strsql,@strwhere);
    PREPARE sql1 FROM @sql1;
    EXECUTE sql1;
    SET _totalcount = FOUND_ROWS();
    
    set @sql2=CONCAT(@strsql,@strwhere,
            CASE
                WHEN _pagesize=0
                THEN ‘‘
            ELSE CONCAT( limit ,@startRow,,,@pageSize)
            END);
  PREPARE sql2 FROM @sql2;
  EXECUTE sql2 ;
    
END

mysql存储过程区别sqlserver

  参数形式,

  分号“;”

mysql 分页存储过程

标签:

原文地址:http://www.cnblogs.com/flywing/p/4971872.html

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