Starter lesson
Page through a stable set of open tasks
A useful query applies filters before returning a small result. A unique tie-breaker in the ordering makes page boundaries predictable when timestamps match.
SELECT id, title, updated_at
FROM tasks
WHERE owner_id = :owner_id
AND status = 'open'
ORDER BY updated_at DESC, id DESC
LIMIT 20;
What to expect
Returns at most 20 open tasks for the requested owner, newest first.
Key idea: Bind owner_id as a query parameter in application code; do not concatenate user input into SQL.