You need to select entries with date which is less than the current date for 7 days and not more than 30 days.
Example: (Imagine that today 2018-11-28)
id | Дата 1 | 2018-12-28 2 | 2018-12-22 3 | 2018-10-27 It should display only the second entry. (2018-12-21) because It falls into this gap. My unsuccessful attempt:
SELECT `user_id` FROM users WHERE user_last_activity <= CURDATE()-6 AND user_last_activity > CURDATE()-30
user_last_activity? - Igor