如何取得select得到的数据的中间几条???

    技术2022-05-11  63

    1、如取得第6到8条记录(该表共有1000条数据)   2、如何取得第20-40第的记录(该表共有1000条数据)     ---------------------------------------------------------------   select  *  from  aa  WHERE  Between(Recno()  ,  6,  8)     select  *  from  aa  WHERE  Between(Recno()  ,  20,  40)   ---------------------------------------------------------------     你可以使用Between(Recno()  ,  20,  40)     另外,最好先将结果按顺序保存到一个临时表,然后再使用recno()来定位记录,避免原表中删除记录对recno()的影响   ---------------------------------------------------------------   先把前40选出来插到一个临时表中,并按降序,再选出前20条不是可能了吗   ---------------------------------------------------------------     select  top  3  *  from  aa   where  KeyID  not  in  (select  top  10  *  from  aa  )   取得第11到第13条记录   ---------------------------------------------------------------   1﹑可以先把記錄指針定位到第N條﹐然后再用范圍語句NEXT即可        如﹕go  6                select  *  from  aa  next  3   2﹑select  *  from  aa  WHERE  Between(Recno()  ,  20,  40)        這條語句用了函數﹐很好﹗   3﹑select  top  3  *  from  aa        where  KeyID  not  in  (select  top  10  *  from  aa  )        取得第11到第13条记录        也很好  

    最新回复(0)