如何查找数据表中从第5个到第10个的数据?

解决方案 »

  1.   

    select top 5 * from a 
    where id not in (select top 5 id from a )
      

  2.   

    参考:http://community.csdn.net/Expert/topic/4981/4981750.xml?temp=.5286066
    http://community.csdn.net/Expert/topic/4948/4948096.xml?temp=.4532282
    http://community.csdn.net/Expert/topic/4932/4932893.xml?temp=.4125788
    http://community.csdn.net/Expert/topic/4922/4922745.xml?temp=.4088556
      

  3.   

    select top 5 ar_title,ar_id,ar_ishot,ar_ishot,ar_savepathfilename,ar_content,ar_abstract,ar_author ,ar_from from ce_articles  where ar_isshow='Y' and ar_page=1 and left(ar_category,"&len("->1751->1884->")&")='->1751->1884->' order by ar_sort asc,ar_id desc  那请问这条语句怎么改呢
      

  4.   

    select top 5 ar_title,ar_id,ar_ishot,ar_ishot,ar_savepathfilename,ar_content,ar_abstract,ar_author ,ar_from 
    from ce_articles  where ar_isshow='Y' and ar_page=1 and left(ar_category,len('->1751->1884->'))='->1751->1884->' 
    order by ar_sort asc,ar_id desc  
    --这样?
      

  5.   

    and left(ar_category,"&len("->1751->1884->")&")='->1751->1884->' 这句什么意思???
      

  6.   

    取n到m条记录的语句1.
    select top m * from tablename where id not in (select top n * from tablename)2.
    select top m * into 临时表(或表变量) from tablename order by columnname -- 将top m笔插入
    set rowcount n
    select * from 表变量 order by columnname desc3.
    select top n * from 
    (select top m * from tablename order by columnname) a
    order by columnname desc
    4.如果tablename里没有其他identity列,那么:
    select identity(int) id0,* into #temp from tablename取n到m条的语句为:
    select * from #temp where id0 >=n and id0 <= m如果你在执行select identity(int) id0,* into #temp from tablename这条语句的时候报错,那是因为你的DB中间的select into/bulkcopy属性没有打开要先执行:
    exec sp_dboption 你的DB名字,'select into/bulkcopy',true
    5.如果表里有identity属性,那么简单:
    select * from tablename where identitycol between n and m 
      

  7.   

    还是出错啊
    Microsoft OLE DB Provider for SQL Server 错误 '80040e14' 
    当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。
     
      

  8.   

    简单的正解:
    select top 5 * from a where id in (select top 10 id from a order by id ) order by id 
      

  9.   

    简单的正解--更正,少写了排序:
    select top 5 * from a where id in (select top 10 id from a order by id ) order by id desc
      

  10.   

    用自动增量的虚拟表
    select top 10 * ,identity(int,1,1) tid into #tb from tablename
    select * from #tb
    where tid >=5