MySql data query by time period (instance description ). The time format is 2008-06-16. query the data of the current day: SELECT * FROM 'table' WHEREdate (time field) curdate (); query the current month field: SELECT * FROM 'table' WHEREmonth (the time format of the time field is 2008-06-16
Query the data of the current day:
SELECT * FROM 'table' WHERE date (time field) = curdate ();
Query the current month field:
SELECT *
FROM 'table'
WHERE month (time field) = month (now ());
The time format is 1219876 ...... UNIX time, as long as the "FROM_UNIXTIME ()" function is applied
For example, query the current month:
SELECT *
FROM 'table'
WHERE month (from_unixtime (reg_time) = month (now ());
Query the last month? Work around!
SELECT *
FROM 'table'
WHERE month (from_unixtime (reg_time) = month (now ()-1;
That's simple. I will try again later!
To query the data of the current day, SELECT * FROM 'table' WHERE date (time field) = curdate (); to query the fields of the current month: SELECT * FROM 'table' WHERE month (time field...