Как получить строки, которые не превышают 900 секунд за последние 24 часа, по unixstamp? Спасибо
CREATE TABLE `users` (
`id` int(10) UNSIGNED NOT NULL, // User ID
`regdate` int(10) UNSIGNED NOT NULL DEFAULT '0', // Registration date in UNIX timestamp
`lastactive` int(10) UNSIGNED NOT NULL DEFAULT '0', // Last active date in UNIX timestamp
`lastvisit` int(10) UNSIGNED NOT NULL DEFAULT '0', // Last visit date in UNIX timestamp
`lastpost` int(10) UNSIGNED NOT NULL DEFAULT '0' // Last post date in UNIX timestamp
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `users` (`id`, `regdate`, `lastactive`, `lastvisit`, `lastpost`) VALUES (13, 1569915390, 1583430726, 1583425902, 1583378778);
/*
* regdate = 1569915390 = Tuesday, October 1, 2019 7:36:30 AM
* lastactive= 1583430726 = Thursday, March 5, 2020 5:52:06 PM
* lastvisit = 1583425902 = Thursday, March 5, 2020 4:31:42 PM
* lastpost = 1583378778 = Thursday, March 5, 2020 3:26:18 AM
*
* 1. On connection and other activity, the lastactive is updated with time ()
*
* 2. If the session cookie is older than 900 seconds then lastvisit is updated from lastactive
*
* 3. When disconnected, lastvisit is updated from lastactive
*/
Вот мой запрос сейчас:
SELECT id
FROM users
WHERE lastvisit > (NOW() - INTERVAL 24 HOUR) AND (NOW() - lastactive < 900)
РЕДАКТИРОВАТЬ: Я думаю, что нашел с помощью @ tadman
SELECT *
FROM users
WHERE lastvisit < (NOW() - INTERVAL 24 HOUR) AND lastactive < (NOW() - INTERVAL 900 SECOND)