zoukankan      html  css  js  c++  java
  • 分页sql

     /// <summary>
            /// 根据页数分页
            /// </summary>
            /// <param name="page"></param>
            /// <param name="pagesize"></param>
            /// <param name="where"></param>
            /// <param name="column"></param>
            /// <returns></returns>
            public static DataSet GetListByPage(int page, int pagesize, string where, string column)
            {
                System.Text.StringBuilder sbu5 = new StringBuilder();
                int num1 = (page - 1) * pagesize;
                int num2 = page * pagesize;
                sbu5.Append("select " + column);
                sbu5.Append(" FROM(");
                sbu5.Append("SELECT A.*, ROWNUM RN FROM (SELECT * FROM tabel WHERE 1=1" + where + ") A WHERE 1=1" + where + " AND ROWNUM <= " + num2);
                sbu5.Append(")");
                sbu5.Append("where RN >" + num1);
                return DbHelperOra.Query(sbu5.ToString());
            }
    
            /// <summary>
            ///  获得数据列表
            /// </summary>
            /// <param name="strWhere"></param>
            /// <param name="column"></param>
            /// <returns></returns>
            public static DataSet GetList(string strWhere, string column)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select " + column);
                strSql.Append(" FROM table");
                if (strWhere.Trim() != "")
                {
                    strSql.Append(" where 1=1 " + strWhere);
                }
                return DbHelperOra.Query(strSql.ToString());
            }
    

      

  • 相关阅读:
    Linux中的防火墙
    Jinja2模板概述
    Ansible触发器-tag标签-忽略错误
    Ansible流程控制
    Ansible变量
    Play-book格式写法
    Redis哨兵(Sentinel)
    Redis 主从复制
    Redis介绍及安装
    Keepalived高可用集群搭建
  • 原文地址:https://www.cnblogs.com/myblogslh/p/4200958.html
Copyright © 2011-2022 走看看