当前位置:网站首页>分页SQL
分页SQL
2022-04-23 13:59:00 【流苏1990】
分页的SQL,这个方法就请求一次
public static StringBuilder SqlPageSql(string strSql, string orderField, bool isAsc, int pageSize, int pageIndex)
{
StringBuilder stringBuilder = new StringBuilder();
if (pageIndex <= 0)
pageIndex = 1;
string str = string.Empty;
if (string.IsNullOrEmpty(orderField) == false)
{
if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0)
str = " order by " + orderField;
else
str = " order by " + orderField + " " + (isAsc ? "asc" : "desc");
}
else
str = "order by (select 0)";
stringBuilder.Append("select * From (select row_number() Over (" + str + ")");
stringBuilder.Append(string.Concat(new object[] { " as rowNum,count(1) over() as totalRecord, * from (", strSql, ") T ) as N where rowNum > ", ((pageIndex - 1) * pageSize), " and rowNum <= ", (pageIndex * pageSize) }));
return stringBuilder;
}
版权声明
本文为[流苏1990]所创,转载请带上原文链接,感谢
https://blog.csdn.net/fuweiping/article/details/95633448
边栏推荐
- 服务器中挖矿病毒了,屮
- Port occupied 1
- UML Unified Modeling Language
- Kettle--控件解析
- Failure to connect due to improper parameter setting of Rac environment database node. Troubleshooting
- Using Jupiter notebook in virtual environment
- Decentralized Collaborative Learning Framework for Next POI Recommendation
- 联想产品经理林林:天津当地网络运营商网络故障 ZUI系统后台服务器暂时无法正常工作
- Analysis of the problem that the cluster component GIPC in RAC environment cannot correctly identify the heartbeat network state
- Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
猜你喜欢

OSS cloud storage management practice (polite experience)

Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"

SQL learning | set operation

Quartus prime hardware experimental development (de2-115 board) experiment 1 CPU instruction calculator design

JS brain burning interview question reward

Jenkins construction and use

STM32学习记录0007——新建工程(基于寄存器版)
![MySQL [read / write lock + table lock + row lock + mvcc]](/img/a9/ace85899a01a7d4fd80b2e631e44d6.png)
MySQL [read / write lock + table lock + row lock + mvcc]

STM32 learning record 0007 - new project (based on register version)

大专的我,闭关苦学 56 天,含泪拿下阿里 offer,五轮面试,六个小时灵魂拷问
随机推荐
L2-024 tribe (25 points)
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
[code analysis (1)] communication efficient learning of deep networks from decentralized data
项目中遇到的问题(五)操作Excel接口Poi的理解
Es introduction learning notes
groutine
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
leetcode--380.O(1) 时间插入、删除和获取随机元素
Ora-600 encountered in Oracle environment [qkacon: fjswrwo]
初探 Lambda Powertools TypeScript
收藏博客贴
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
scikit-learn構建模型的萬能模板
力扣刷题 101. 对称二叉树
RAC environment alert log error drop transient type: systp2jw0acnaurdgu1sbqmbryw = = troubleshooting
2021年秋招,薪资排行NO
The art of automation
freeCodeCamp----arithmetic_ Arranger exercise
Reading notes: fedgnn: Federated graph neural network for privacy preserving recommendation
VsCode-Go