I want to get records after a certain record, say id is 4.
Actually I want to show posts based on likes with pagination.
So I sorted result by likes.
But I don't know how to get the next records based on id.
Here is my code
SELECT urp.* , likes
FROM user_related_posts urp
JOIN (
    SELECT post_id, COUNT(*) AS likes
    FROM post_likes
    WHERE STATUS =1
    GROUP BY post_id
    ) v ON urp.post_id = v.post_id
GROUP BY post_id
ORDER BY likes DESC 
LIMIT 0 , 30
Sorry I don't put image, I don't have enough credentials.
What here doing is when I order with likes, ids are unsorted,
but I want records based on id.


 
     
     
    