0
| id         | first (datetime)    | last (datetime)
--------------------------------------------------------
| 1          | 2013-04-15 00:00:00 | 2013-04-21 23:59:00
| 2          | 2013-04-08 00:00:00 | 2013-04-14 23:59:00
| 3          | 2013-04-01 00:00:00 | 2013-04-07 23:59:00
| 4          | 2013-04-01 00:00:00 | 2013-04-07 23:59:00

如果记录日期时间范围涵盖今天,我想显示记录。(此示例的 3 和 4)

我试着用两个做这个NOW(),它在第二个给出语法错误NOW()

我怎样才能做到这一点?

4

2 回答 2

1
select *
from your_table
where current_date() between first_datetime and last_datetime
于 2013-04-04T16:58:32.680 回答
1
select 
    *
from
    your_table
where
    first <= NOW() 
and last >= NOW()
于 2013-04-04T17:04:07.017 回答