php - MySQL select where the MOST RECENT date is NOT between two dates -
i'm trying run query retrieve customers recent activity not between +/- 30 days. life of me can't figure out.
here's have far:
activity.date not between date_sub(curdate(), interval 30 day) , date_add(curdate(), interval 30 day'
problem need make sure activity.created_on field recent. i'm not sure how go this. i'm joining customers table based on customer_id, if matters.
thanks help
i've similar table structure , works me:
select c.id, c.first_name, c.last_name, max(a.activity_date) date activities join clients c on c.id = a.client_id a.activity_date not between date_sub(curdate(), interval 30 day) , date_add(curdate(), interval 30 day) group c.id order date desc, c.first_name, c,last_name
Comments
Post a Comment