0

我有一张像这样的桌子..

TeacherName         | Class | Section  | SubjectId |    Date   | ToDate    |Day
--------------------------------------------------------------------------------
       Matt         |   12  | B        | Math      |2013-03-04 |2013-03-14 |Mon
       John         |   12  | A        | Phy       |2013-04-03 |2013-04-12 |Mon

我想要这样的查询(不是实际的 sql 查询)...

Select * 
from Table 
where Class='12' and section='B' and Date= '2013-03-07'

这应该给我第一行,Matt因为给定的日期2013-03-07在该行的日期范围内,从2013-03-042013-03-14

这甚至可能吗?

4

1 回答 1

6

利用BETWEEN

SELECT  * 
FROM    TableName
WHERE   Class = '12' AND 
        Section = 'B' AND 
        '2013-03-07' BETWEEN DATE AND TODATE
于 2013-03-04T08:16:14.673 回答