我有两个日期格式一个是2013-01-01到2013-01-10我有时间两个时间一个是20:00:00到23:59:59和00:00:00到07:00 :00我正在使用for循环进行迭代开始日期到结束日期,我期待以下
查询:
select * from user where login >='$starttime' and logout <='$endtime' and date='$StartDate';
期待结果:
select * from user where login >='20:00:00' and logout <='23:59:59' and date='2013-01-01';
select * from user where login >='00:00:00' and logout <='07:00:00' and date='2013-01-02';
如果使用条件来获得期望结果
答案 0 :(得分:0)
select * from user where (login >='20:00:00' and logout <='23:59:59' and date='2013-01-01') OR (login >='00:00:00' and logout <='07:00:00' and date='2013-01-02');
如果时间相同但你需要这个日期范围:
SELECT * FROM `user`
WHERE `login` >='20:00:00' AND `logout` <='23:59:59' AND `date` between '2013-01-01' AND '2013-01-02';