I have a table called 'items'
It has the following columns: id, name, stock, price, and category_id.
My query is
SELECT * FROM items WHERE category_id = {$category_id} LIMIT 10;
my logic for next page is store all ids in a variable called $oldIds and the next query is:
SELECT * FROM items WHERE category_id = {$category_id} AND id NOT IN ($oldIds) LIMIT 10
for another page is i store again the ids from 1st page and 2nd page do again the query
SELECT * FROM items WHERE category_id = {$category_id} AND id NOT IN ($oldIds) LIMIT 10
Do i continue using this style of query or is there a better way of querying?
LIMITandOFFSET