先看看图片 -要求
刚开始呢 我只是简单的认为查询开始和结束时间之间的就可以了。
select * from table fp where WHERE fp.preferential_start_time >= ' 2012-12-11 10:31:36.0' and fp.preferential_end_time <= '2012-12-28 10:31:36.0'
但是这样是查询不出来数据的。
结果sql语句是需要这样来写:
select * from table fp where
( fp.preferential_start_time >= '2012-12-11 10:31:36.0' and fp.preferential_end_time <='2012-12-28 10:31:36.0' )
or ( fp.preferential_start_time >= '2012-12-11 10:31:36.0' and fp.preferential_start_time < '2012-12-28 10:31:36.0')
or ( fp.preferential_end_time > '2012-12-11 10:31:36.0' and fp.preferential_end_time <='2012-12-28 10:31:36.0')
好好体会一下呢!