假设有这么一个SQL语名
select *
from example
order by x
但是我只要前10条,该如何做,
谢谢高手们不啬赐教

解决方案 »

  1.   

    select top 10 * from example order by x
      

  2.   

    如果是MySQL的话应该是
    SELECT * FROM example LIMIT 0, 10
      

  3.   

    可是提示invalid use of keyword
      

  4.   

    select top 10 * from example order by x
      

  5.   

    select top 10 * from example order by x
    是正解
    而提示的非法关键使用一定是其他问题
    你把完整的语句帖出来
      

  6.   

    select top 10 * from example order by x
      

  7.   

    select * from example where rownum <= 10 order by x排个倒序,呵呵 
    select top 10 * from example order by x desc
      

  8.   

    同意楼上,DESC     //倒序
      

  9.   

    但如果数据库为SQL SERVERselect * from example where rownum <= 10 order by x是不成立的.
      

  10.   

    select top 10 * from example order by x  //反正top 10就可以返回数据集的 头10条记录了!
      

  11.   

    select top 10 * from example order by x
      

  12.   

    设返回的行数为n
    select top n * from example order by x
      

  13.   

    还可以用
    SET ROWCOUNT @n    
    select * from example order by x
    SET ROWCOUNT 0
      

  14.   

    使用TOP 10 只能 是ACCESS或 SQL SERVER数据库,如果用paradox 或DBF就不行了
    我也来听听怎样在DBF和PARADOX中实现这个功能
      

  15.   

    不行,因为我的数据库是paradox