Hey guys, I am trying to update rows that have a status "future" for today and all days before today. Here is what I am using so far: But it seems to not work. Is there a better way to do this?
What type of data is the column `post_date`? Assuming that post_date is a date type column, this query may be doing more harm than good... DATE(post_date)<='$date_today'
You should be able to simply use: WHERE post_date <= '$date_today' There's 2 problems that you would experience using WHERE DATE() or WHERE FUNCTION().. First off, if you use any function: CAST, MAX, DATE, TIME, etc... in the where clause, MySQL cannot utilize an index on the column. This may or may not be an issue depending on whether you have an index on the column or not. If there is an index, it is ignored. Second problem, is that the function could be applied to the entire column before any sorting will be performed. If your database has 100 records, it's essentially negligible, but performing DATE() on 10,000,000 records would create a huge amount of overhead for a simple date comparison. Same thing goes with any function in the where clause.
thanks a ton man. I figured the the two dates had to be in the same long format to work, and what you said makes sense, so I'll just clip that DATE() right off.