LIMIT and OFFSET

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:30 PM on 9/30/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

LIMIT

Limits how many rows are returned. Example: LIMIT 5 returns only 5 rows.

2
New cards

OFFSET

Skips a number of rows before returning results. Example: OFFSET 3 skips the first 3 rows.

3
New cards

LIMIT and OFFSET syntax

SELECT * FROM table_name ORDER BY column_name LIMIT 5 OFFSET 10;

4
New cards

LIMIT example

SELECT full_name, gpa FROM Students_Spring2024 ORDER BY gpa ASC LIMIT 3; Returns the 3 lowest GPAs.

5
New cards

Why ORDER BY matters

Use ORDER BY before LIMIT/OFFSET for consistent pages. Without sorting, row order may not be reliable.

6
New cards

First page example

Page size 8: ORDER BY student_id LIMIT 8 OFFSET 0;

7
New cards

Second page example

Page size 8: ORDER BY student_id LIMIT 8 OFFSET 8;

8
New cards

Third page example

Page size 4: ORDER BY major LIMIT 4 OFFSET 8; Skips pages 1 and 2, then returns page 3.

9
New cards

Pagination formula

OFFSET = (page number − 1) × page size. Example: page 3 with 4 rows per page = OFFSET 8.

10
New cards

LIMIT vs. OFFSET

LIMIT controls how many rows you get; OFFSET controls how many rows you skip first.