当前位置:Gxlcms > 数据库问题 > MYSQL查询一周内的数据(最近7天的)

MYSQL查询一周内的数据(最近7天的)

时间:2021-07-01 10:21:17 帮助过:3人阅读

select * from wap_content where week(created_at) = week(now)

如果你要严格要求是某一年的,那可以这样

查询一天:

select * from table where to_days(column_time) = to_days(now());
select * from table where date(column_time) = curdate();

查询一周:

select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);

查询一个月:

select * from table where DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) <= date(column_time);


MYSQL查询一周内的数据(最近7天的)

标签:

人气教程排行