#修改7天内有效fromID status = 2(用来发模板)
update fromID SET status = 1 where id in(select a.id from (SELECT b.id FROM fromID b WHERE b.status = 0 AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= date(b.create_time) GROUP BY b.openid) a)
按月份查询
SELECT COUNT( create_time ) Total, date_format( create_time, '%d' ) time, date_format( create_time, '%Y%m%d' ) day FROM {$tableName} WHERE date_format( create_time, '%Y %m' ) = date_format( DATE_SUB( curdate( ), INTERVAL {$month} MONTH ), '%Y %m' ) GROUP BY date_format( create_time, '%Y%m%d' )