Let say I have a post table. But I want to query all today post. But if today post is less than 10 post, I will get back the yesterday post to query. If it is more than 10 posts, no need to query yesterday post….If SQL statement can’t do it. Is this only achieve it by calling the post manually….? Thank you.
***The database is MySQL
Let me clarify the question in a typical example:
If today have 5 posts….ONLY. And yesterday have 10 posts.
return : 5 today posts, and 5 posts from yesterday
If today have 12 posts....ONLY.
And yesterday have 10 posts.
return : 12 today posts.
If today have 10 posts….ONLY. And yesterday have 10 posts.
return : 10 today posts.
If today have 2 posts....ONLY. yesterday have 5 posts, and the day before yesterday 5posts.
return : 2 today posts, 5 yesterday posts, 3 the day before yesterday posts.
You can try
and if the result is > 10 then
else