Bird
Raised Fist0

Given this SQL query for keyset pagination:

medium📝 Predict Output Q4 of Q15
Rest API - Pagination Patterns
Given this SQL query for keyset pagination:
SELECT * FROM products WHERE id > 100 ORDER BY id ASC LIMIT 5;

What will be the result if the highest id in the table is 102?
AReturns 5 rows starting from id 100
BReturns no rows
CReturns 2 rows with id 101 and 102
DReturns all rows with id less than 100
Step-by-Step Solution
Solution:
  1. Step 1: Analyze WHERE condition

    WHERE id > 100 means rows with id 101 and above are selected.
  2. Step 2: Check available rows and LIMIT

    Only ids 101 and 102 exist above 100, so only 2 rows returned despite LIMIT 5.
  3. Final Answer:

    Returns 2 rows with id 101 and 102 -> Option C
  4. Quick Check:

    Rows returned = 2 [OK]
Quick Trick: LIMIT caps rows, but fewer rows may be returned [OK]
Common Mistakes:
MISTAKES
  • Assuming LIMIT always returns full count
  • Ignoring WHERE filter effect
  • Confusing id > 100 with id >= 100

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes