I have a delete clause that deletes rows from my database where the 'viewed' column datetime value is older than 24 hours. I have that code working great, except the default value for the viewed column is 0000-00-00 00:00:00. In this case, every row of data with the default value gets deleted as well. How can I change my query to keep this from happening?
My Code:
$delete_expired_notifications_query= "DELETE FROM notifications WHERE user_id= '".$u_id."'
AND viewed < NOW() - INTERVAL 24 HOUR";
Thanks