I want to get a user's posts in their wall, and I want to limit the number of records I get. I'm doing so using this query:
SELECT post_id, message, attachment, type, place, updated_time FROM stream WHERE source_id = me() AND actor_id = source_id AND type IN (46, 80, 128, 247) LIMIT 10
So far so good. The problem with this is that if I have a total of, for example 100 posts, and in the first 10 I have 5 that meet the ends of my query, when I put LIMIT 10
I only get those 5 results, because the LIMIT
filter is applied on the first query conditions, and not on the total results from that table.
As a temporary workaround I changed my query to this: SELECT post_id, message, attachment, type, place, updated_time FROM stream WHERE post_id IN (SELECT post_id FROM stream WHERE source_id = me() AND actor_id = source_id AND type IN (46, 80, 128, 247) LIMIT 100) LIMIT 10
But this isn't bulletproof, since I am only expanding my possible list of wanted results so I have a higher number to select from.
So, how could I query the wanted results?