我想查询在某一个时间段的在线记录
表A中有下面字段,开始时间:2011-03-03 12:00:00
结束时间: 2011-03-05 12:00:00现在要查询的是,在某一个时间段在在线记录比如说 :2011-03-03 15:00:00   2011-03-03 18:00:00 这在这个时间段的在线记录如果这个时间在记录的开始和结束时间中就查询出来的不好意思,分不够了~只有这点

解决方案 »

  1.   

    select count(*) from 表A
    where 开始时间<='2011-03-03 12:00:00' and 结束时间>='2011-03-05 12:00:00'
      

  2.   

    select count(*) from A where 开始时间='2011-03-03 15:00:00' and 结束时间='2011-03-05 18:00:00'
      

  3.   

    select count(*) from 表A
    where 开始时间<='2011-03-05 12:00:00' and 结束时间>='2011-03-03 12:00:00'
      

  4.   

    select count(*) from 表A
    where 开始时间<='2011-03-03 12:00:00' and 结束时间>='2011-03-05 12:00:00' group by user
    或select count(*) from 表A
    where between '2011-03-03 12:00:00' and  '2011-03-05 12:00:00' group by user暂定你登陆用户是user