php - Getting Newest Records from MySQL (7 days) -
i trying grab newest records table. want of records happened in past 7 days. here have far start with.
$query = "select * mlg_logattempts a.ts = (select max(ts) mlg_logattempts b b.ts > now() - interval 5 minute , b.name = a.name)";
i have used intervals in past unsure how make work now. can show me proper way request past 7 days records? have timestamp field.
update
unfortunately realized command shared you. not have of above fields. date field have "date". no or ts.
you use mysql date_diff() dates http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff
but since use timestamps, interval solution:
b.ts > unix_timestamp(curdate()-interval 7 day)
Comments
Post a Comment