How does MySQL count the previous day records? The time storage mode is:
CREATE TABLE ' Bean ' (
' usedate ' varchar () default NULL,
Statistics Bean Database Date field: Usedate
Write this:
SELECT * from beans where date (usedate) = Date_sub (Curdate (), Interval 1 day);
But there is an error, prompting:
Warning:mysql_num_rows (): supplied argument is not a valid MySQL result resource in
Perhaps the above MySQL statement can only be counted out y-m-d hh:mm such storage format of time, if the time is stored as 1340508737, please ask if the statistics of the previous day's record?!
Thank you!
It's not possible to change this:
SELECT * from Beans where to_char (usedate, ' yyyy-mm-dd ') = Date_sub (Curdate (), Interval 1 day);
------Solution--------------------
SQL Code
SELECT * from ' Beans ' WHERE from_unixtime (' usedate ', '%y-%m-%d ') = Date_sub (Curdate (), INTERVAL 1 day)