So, I need to make MySQL query where I select data according to time.
1| SET @t = 1490894826;
2| SELECT id
3| FROM table
4| WHERE status=1 AND
5| fav>500 AND
6| time BETWEEN @t-86400 AND @t
7| LIMIT 10
My question is, I need 10 rows from this query, but if it gives me 7 rows(for example), how can I set my query to do it again and again while number of selected rows is not 10 or time is bigger than 1480531730, and every next time @t variable needs to be substracted by 86400. Sorry for my english, take a look how I did it using PHP just to show you what I really want and I hope it will be more clearly.
$time=1490894826;
do{
$query = $db->query("SELECT * FROM table WHERE status=1 AND fav>500 AND time BETWEEN ? AND ? LIMIT 10",[$time-86400,$time]);
$time=$time-86400;
}while($query->rowCount()!=10||$time>1480531730);
Thank you