如有   id    time
       1     2007-01-01
       1     2007-05-06
       2     2007-02-02
       2     2007-05-08
如何找出2007-05-05时间之前的数据,即:
       id    time
       1     2007-01-01
       2     2007-02-02

解决方案 »

  1.   

    select * from tb where time < '2007-05-05'
      

  2.   

    这样好象可以:
    select * from data where rectime=(select max(rectime) from data where rectime < '2006-03-06 08:43:48' and ssid=1)
    UNION ALL
    select * from data where rectime=(select max(rectime) from data where rectime < '2006-03-06 08:43:48' and ssid=2) 但是我ssid数量是不固定的,如何从最小id查到最大的?
      

  3.   

    select a.* from tb a , 
    (select id , max(time) as time from tb where time < '2007-05-05') b
    where a.id = b.id and a.time = b.time
      

  4.   

    select * from tb where time< '2007-05-05'