如何从PHP中的SQL Server获取20到20条记录

时间:2015-07-06 11:10:07

标签: php sql sql-server

select 
   TOP 20 * 
from 
  (select 
     TOP 30 *
   from SavingRecurringMst_Kuber r, BhishiRegistrationMst b,  
        SavingRegistrationMst_Kuber s 
   where 
       RegID = FKRegID and 
       PkSavingRegID = FKSavinRegID ) as T 
ORDER BY 
   Transactionate DESC

1 个答案:

答案 0 :(得分:1)

试试这个......! 将起始索引和结束索引作为UI中的参数传递。

select SLNO, T.*
from  (
         select 
          ROW_NUMBER() OVER (ORDER BY Transactionate DESC) AS SLNO , SavingRecurringMst_Kuber.*
       from SavingRecurringMst_Kuber r, BhishiRegistrationMst b,  
            SavingRegistrationMst_Kuber s 
       where 
           RegID = FKRegID and 
           PkSavingRegID = FKSavinRegID    
       ) as T 
 where T.SLNO >= P_STARTINDEX and T.SLNO <= P_ENDINDEX