UPDATE `users` SET `logout_date`='2018-07-19 09:48:40' WHERE UNIX_TIMESTAMP(DATE_SUB('2018-07-19 09:48:40', INTERVAL 1440 SECOND)) > UNIX_TIMESTAMP(last_request_time) AND (`logout_date` ='1000-01-01 00:00:00')