MySQL + SQL · Lesson 51

LIMIT and OFFSET in MySQL

LIMIT — Restrict Rows

SELECT * FROM students ORDER BY marks DESC LIMIT 3;
Returns only the top 3 students by marks.

OFFSET — Skip Rows

SELECT * FROM students LIMIT 5 OFFSET 10;
-- same as
SELECT * FROM students LIMIT 10, 5;

Skips 10 rows, then returns 5 — used for pagination (page 3 of results).

Summary

  • LIMIT n = return at most n rows.
  • OFFSET skips rows; together they power pagination.
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

WhatsApp