天天看點

簡單按日期查詢mysql某張表中的記錄數

測試表表結構:

mysql> show create table dr_stats\G

1. row

查詢一張表中一年的中4月份的資料:

查詢dr_stats表2016年 4月1日至2016年4月21日的資料記錄數:

2016年 4月1日至2016年4月21日這個dr_stats表是沒有資料的

查詢dr_stats表2016年 4月1日至2016年4月22日的資料記錄數:

查詢dr_stats表2016年 4月22日至2016年4月23日的資料:

time mysql -uroot -p'ZykJ7' -S /tmp/mysql.sock -e 'use drnew;select * from dr_stats where 1 and year(day)=2016 and month(day)=04 and day(day) between 22 and 23;' >>/root/txt04

查詢dr_stats表2016年 4月22日至2016年4月22日的資料:

查詢dr_stats表2016年 4月21日至2016年4月22日的資料:

 本文轉自 wjw555 51CTO部落格,原文連結:http://blog.51cto.com/wujianwei/2065978

繼續閱讀