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.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.