This will select all expired ads: $sql = "SELECT adid FROM $t_ads WHERE expireson < NOW()"; I need to selected ads if they expired 30+ days ago. How would you do that? Thanks!
SELECT something FROM tbl_name -> WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col Code (SQL): That's the 1st example from following ref page: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html Would that work?
That example wanted to select all records. Not sure why. This worked though: $sql = "SELECT adid FROM $t_ads WHERE expireson < NOW() - INTERVAL 30 DAY";
What type of column is expireson? You probably also want to limit how far back you go - say, another 30 days - to target the recently expired.
I don't want to limit. As long as they expired 30+ days ago I want to select (and then remove) them all to keep my db clean from the old, expired ads. If somebody didn't care to renew their ads for 30+ days, they probably don't care if they ever renew them.
Ahem. There were 30K+ expired ads. Some of them expired over a year ago, it was time to get rid of them.