Skip to content
C

Next Page After ID 3

Mediumsql

Using keyset pagination (not OFFSET), fetch the next page of 3 products after the last-seen id of 3, ordered by id ascending. Return id, name.

sql
CREATE TABLE products ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, category TEXT NOT NULL, price INTEGER NOT NULL );

Sample data:

sql
INSERT INTO products (id, name, category, price) VALUES (1, 'ProLaptop', 'Electronics', 85000), (2, 'Desk Lamp', 'Home', 900), (3, 'ProPhone', 'Electronics', 45000), (4, 'Python Basics', 'Books', 350), (5, 'Novel', 'Books', 220), (6, 'Headphones', 'Electronics', 3000), (7, 'Rug', 'Home', 4500);

Input (stdin)

Output

Run your code to see output here...