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);
查询一年:
select * from table where DATE_SUB(CURDATE(), INTERVAL 1 YEAR) <= date(column_time);
扩展资料
mysql查询最近7天的数据:
1,(以当天为起点)
SELECT * FROM tb_equity e where DATE_SUB(CURDATE(), INTERVAL 6 DAY) <=
date(createdate)
2,(以数据库最新的时间最为最近的一天)
SELECT * FROM tb_equity e where createdate > DATE_ADD((select createdate from tb_equity
ORDER BY createdate DESC limit 1) ,INTERVAL -7 day)
and (select createdate from tb_equity ORDER BY createdate DESC limit 1) >= createdate
3,sql查询表中的重复数据
select * from 表名 where 字段名 in (select 字段名 from 表名 group by 字段名 HAVING COUNT(*)
> 1) order by 表名
参考资料来源:百度百科 - 结构化查询语言
参考资料来源:百度百科 - mySQL (关系型数据库管理系统)
参考资料来源:百度百科 - select (Linux 网络编程)