Deleting the user from Tuser when the user didnt login within 24 hours
When the authentication code in the Tuser is not null it means the users didnt login the site within 24 hours so i have to delete the rows.
Here is the query which I wrote but it is not deleting correctly
DELETE FROM tusers WHERE auth_code IS NOT NULL AND auth_code !='' AND STR_TO_DATE(NOW(),'%Y-%m-%d %T') > (DATE_SUB(STR_TO_DATE(created_date,'%Y-%m-%d %T'),INTERVAL -1 DAY))
You are in a better position to determine whether it is right or not by testing and letting us know if it works or not.
But I can tell you that it is more complicated than it needs to be. You can compare dates directly like this:
... where date(now()) > date_sub(created_date, interval 1 day)
Note that if you are going to SUBTRACT a day in order to go back, you should subtract a positive number of days. Subtracting a negative number of days refers to later in time, not earlier.
I got the perfect delete which is working perfectly:
DELETE FROM tusers WHERE auth_code IS NOT NULL AND auth_code !='' AND DATE_SUB(NOW() , INTERVAL 24 HOUR) > STR_TO_DATE(created_date,'%Y-%m-%d %T');
This query deletes the rows by comparing the current date of the system with the created date of the rows which reaches above 24 hours of the current date.