递归算法+sql三种分页

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归算法+sql三种分页相关的知识,希望对你有一定的参考价值。

using Maticsoft.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Maticsoft.Web.cest
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        Maticsoft.BLL.lhzExcSQL lhz = new BLL.lhzExcSQL();
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(Fun(4));
            if (!IsPostBack)
            {
                Fun(30);
            }
        }
        //递归算法    1,1,2,3,5,8,13 求第n位数是多少?
        public int Fun(int n)
        {
            if (n < 1) return 0;
            if (n == 1 || n == 2) return 1;
            else return Fun(n - 1) + Fun(n - 2);
        }
        //三种常见分页
        //DataTable dt = lhz.GetTalbe("select nid,ntitle from news order by nid OFFSET (5 * (1-1)) ROW FETCH NEXT 5 rows only");
        //DataTable dt = lhz.GetTalbe("select top 5 nid,ntitle from news where nid not in (select top 0 nid from news order by nid) order by nid");
        //DataTable dt = lhz.GetTalbe("select * from (select top 5 nid,ntitle,ROW_NUMBER() over(order by nid) r from news) tt where tt.r between 1 and 5");
    }
}

 

以上是关于递归算法+sql三种分页的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch 三种分页方式

Asp.Net中的三种分页方式总结

Sqlserver 数据库分页查询(三种方式)

MyBatis的三种分页方式,你用过几种?

MyBatis的三种分页方式,你用过几种?

java分页查询