表class:
-------------
id   name
1   文学
2   政治
...表book:
-------------
id  name class_id add_time
1   彷徨    1      2007-08-20 18:25:30
....
怎样查找出今日(即从00:00:00 到现在的时刻)有新书加入的class?

解决方案 »

  1.   

    select * from class where id in (select class_id from book where day(add_time) = day(now()));
      

  2.   

    表book: (可以认为这个表本身就是一个今天的图书新增表,然后查询该表即可。)
    select c.id,c.name
    from class c,book b
    where b.class_id=c.id AND 
          (b.add_time between 00:00:00 and current_time());
      

  3.   

    表book: (可以认为这个表本身就是一个今天的图书新增表,然后查询该表即可。) 
    select * from class where id in (select class_id 
                                     from book 
                                     where dayofyear(add_time) = dayofyear(now()));