正在生效:
select id from table where find_in_set(month(curdate(),allowmonth) and unix_timestamp(curdate()) between unix_timestamp(sdate) and unix_timestamp(edate);
即将生效:
select id from table where unix_timestamp(curdate()) between unix_timestamp(sdate) and time_stamp(edate);
已经过期:
select id from table where unix_timestamp(curdate()) > unix_timestamp(edate);
select id from table where find_in_set(month(curdate(),allowmonth) and unix_timestamp(curdate()) between unix_timestamp(sdate) and unix_timestamp(edate);
即将生效:
select id from table where unix_timestamp(curdate()) between unix_timestamp(sdate) and time_stamp(edate);
已经过期:
select id from table where unix_timestamp(curdate()) > unix_timestamp(edate);
select id from table where locate(month(curdate(),allowmonth)=0 and unix_timestamp(curdate()) between unix_timestamp(sdate) and time_stamp(edate);
FROM tbl
WHERE locate( month( curdate( ) , disp_month ) =0 AND unix_timestamp( curdate( ) )
BETWEEN unix_timestamp( 'b_date' ) AND time_stamp('e_date'
) MySQL 返回:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' disp_month ) =0 AND unix_timestamp( curdate( ) )
BETWEEN unix_timestamp( '' at line 3
FROM Travel
WHERE locate( month( curdate( ) , disp_month ) =0 AND unix_timestamp( curdate( ) )
BETWEEN unix_timestamp( b_date ) AND unix_timestamp( e_date ) MySQL 返回:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' disp_month ) =0 AND unix_timestamp( curdate( ) )
BETWEEN unix_timestamp( b_' at line 3
find_in_set(month(curdate(),allowmonth))
find_in_set(month(curdate()),allowmonth)
locate(month(curdate()) , disp_month)
试试
id sdate edate allowmonth (注:允许发生的月份)
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第六条数据呢..你的算法能判断出来么?这个应该属于过期的了..