当前位置:网站首页>分页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
边栏推荐
猜你喜欢
JS brain burning interview question reward
初探 Lambda Powertools TypeScript
3300万IOPS、39微秒延迟、碳足迹认证,谁在认真搞事情?
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
神经元与神经网络
Wechat applet
crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
程序编译调试学习记录
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
Basic SQL query and learning
随机推荐
Jenkins construction and use
Leetcode brush question 𞓜 13 Roman numeral to integer
MySQL [SQL performance analysis + SQL tuning]
Express ② (routing)
Analysis of cluster component gpnp failed to start successfully in RAC environment
神经元与神经网络
Use future and countdownlatch to realize multithreading to execute multiple asynchronous tasks, and return results after all tasks are completed
Quartus Prime硬件实验开发(DE2-115板)实验二功能可调综合计时器设计
Small case of web login (including verification code login)
scikit-learn構建模型的萬能模板
json反序列化匿名数组/对象
Kettle--控件解析
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
金蝶云星空API调用实践
JS 力扣刷题 102. 二叉树的层序遍历
Ora-16047 of a DG environment: dgid mismatch between destination setting and target database troubleshooting and listening vncr features
Analysis of unused index columns caused by implicit conversion of timestamp
【报名】TF54:工程师成长地图与卓越研发组织打造
美联储数字货币最新进展
程序编译调试学习记录