Sybase offset for pagination

前端 未结 7 2106
旧巷少年郎
旧巷少年郎 2020-12-06 14:14

Is there any simple way to implement pagination in sybase? In postgres there are limit and offset in mysql there is limit X,Y. What about sybase? There is top clausure to li

7条回答
  •  萌比男神i
    2020-12-06 14:35

    // First row = 1000
    // Last row = 1009
    // Total row = 1009 - 1000 + 1 = 10
    // Restriction: exec sp_dboption 'DATABASE_NAME','select into/bulkcopy','true'
    select TOP 1009 *, rownum=identity(10) 
    into #people
    from people 
    where upper(surname) like 'B%'
    select * from #people where rownum >= 1000
    drop table #people
    // It shoulde be better SQL-ANSI-2008 (but we have to wait):
    // SELECT * FROM people
    // where upper(surname) like 'B%'
    //    OFFSET 1000 ROWS FETCH NEXT 10 ROWS ONLY
    

提交回复
热议问题