I am trying to execute a SQL query which first sorts the data with the most recent one in row 1, and then returns all entries from row 1 up to an entry with a particular ID. The purpose of this is to load content to a mobile app, and when the user refreshes the content, only the content which is newer than the newest one he has already loaded is returned. So far I came up with this :
$all_feed_posts = mysqli_query($conn,"SELECT *
WHERE city_geo_name_id = '$geo_name_id'
ORDER BY timestamp DESC
LIMIT WHERE feed_instance_id = $offset");
If you have last id been read in
$offset var then you can just add
AND into your clause.
I guess all newer records should have
feed_instance_id > $offset:
SELECT * FROM feed_img_vid WHERE city_geo_name_id = '$geo_name_id' AND feed_instance_id > $offset ORDER BY timestamp DESC