SQL语句中如何查询超过7天的数据?
如回单表中有字段:id,time,state,address,
字段state为:已回单或未回单,
查询超过7天未回单的数据

解决方案 »

  1.   

    在表中增加一个字段date,存数据存入时间,sql语句查询时这样:select * from tableName where date < '2002-1-12';其中后面的日期即本机现在的日期减去7天。
      

  2.   

    time表示什么,如果是表示数据插入时间,那么select * from table_name where time<=sysdate-7 and state = '未回单'
      

  3.   


    MYSQL:
    select * from `order` a 
    where state='未回单' and datediff(now(),time)>7;
      

  4.   

    什么数据库?
    time字段是什么
      

  5.   

    oracle:
    select * from tbl where time<=trunc(sysdate-7) and state ='未回单';--精确到时分秒
    select * from tbl where time<=trunc(sysdate)-7 and state ='未回单';--从当天00:00:00算起7天前