另帮忙把下面的语句改为按时间查询最近1000条记录 
SELECT DISTINCT * FROM basetuple WHERE ckpointid='"+ckPointID+"' " + 
" ORDER BY cktime LIMIT " + limit + " OFFSET " + offset; 
表结构为ckpointid(varchar 16);cktime(datatime);timeperature(double) 先谢谢

解决方案 »

  1.   

    SELECT DISTINCT * FROM basetuple WHERE ckpointid='"+ckPointID+"' " +
    " ORDER BY cktime LIMIT 1000 order by time desc"  
      

  2.   

    ,ysql help:
    With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1): SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15
      

  3.   


    高手能解释下OFFSET的用法吗
      

  4.   

    LIMIT子句可以被用来限制SELECT语句返回的行数。LIMIT取1个或2个数字参数,如果给定2个参数,第一个指定要返回的第一行的偏移量,第二个指定返回行的最大数目。初始行的偏移量是0(不是1)。 
    mysql> select * from table LIMIT 5,10;  # Retrieve rows 6-15如果给定一个参数,它指出返回行的最大数目。 mysql> select * from table LIMIT 5;     # Retrieve first 5 rows换句话说,LIMIT n等价于LIMIT 0,n。 
      

  5.   

    OFFSET 起的是什么作用  先谢谢WWWWB
      

  6.   

    没有仔细看过上述说明?
    LIMIT [offset,] rows
    OFFSET
    第一个指定要返回的第一行的偏移量,第二个指定返回行的最大数目。初始行的偏移量是0(不是1)。
      

  7.   

    这个数据库中 可能有几百万条温度的数据,用LIMIT 能解决WEB页面速度反应慢的问题不能 好像有什么数据库优化的技术吧 小弟菜鸟