查询一天:
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 1 MONTH) <= date(column_time);
更新待续……
可以在num上设置默认值0,确保表中num列没有null值,然后这样查询:
select id from t where num=0
可以这样查询:
select id from t where num=10
union all
select id from t where num=20
可以改为强制查询使用索引:
select id from t with(index(索引名)) where num=@num