MySql 查詢一周內最近7天記錄


本周內:
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();


查詢7天:
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);

 

轉自:http://blog.163.com/very_apple/blog/static/2775923620133210232571/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM