mysql查询30天内的数据的方法:执行sql语句【select * from 表名 where date_sub(curdate(), interval 30 day) <= date(时间字段名);】即可。
今天:
(推荐教程:mysql教程)
select * from 表名 where to_days( 时间字段名) = to_days(now());
昨天:
select * from 表名 where to_days( now( ) ) - to_days( 时间字段名) <= 1;
7天前:
select * from 表名 where date_sub(curdate(), interval 7 day) <= date(时间字段名);
30天:
select * from 表名 where date_sub(curdate(), interval 30 day) <= date(时间字段名);
本月:
select * from 表名 where date_format( 时间字段名, '%y%m' ) = date_format( curdate( ) , '%y%m' );
相关推荐:php培训
以上就是mysql如何查询30天内的数据的详细内容。