日期:2014-05-16  浏览次数:20734 次

时间判断查询..
travel_id             b_date             e_date         disp_month   (注:允许发生的月份)                
1                       2006-12-12         2008-12-12         1,2,3,4,10,12
2                       2006-11-12         2007-12-12         1,9
3                       2006-1-12         2006-12-12           1,2,9
4                       2006-2-12         2005-12-12           1
5                       2006-12-12         2008-12-12         10,12
6                       2006-12-12         2007-12-12         1


怎样看选出来   哪个id   即将生效(如果正在生效不记入即将生效范围内)   ,哪个正在生效,哪个已经过期.   时间已当前时间为准

即将生效   id   5   ,2
正在生效   id   1
已经过期   id   3,4,6       主要是id=6的怎么判断   .

------解决方案--------------------
SELECT CONVERT(replace(right( disp_month,2) , ', ', ' '),SIGNED),disp_month
FROM `Travel`
WHERE disp_month <> ' ' and CONVERT(replace(right( disp_month,2) , ', ', ' '),SIGNED) > month(curdate())