OFFSET is used to skip a specific number of rows before starting to return rows from a query. It's especially helpful in pagination where you want to display records in chunks (like 10 per page).
SELECT column1, column2
FROM table_name
ORDER BY column_name
LIMIT count OFFSET start;
If you want to fetch the 6th to 10th records, skip the first 5 using OFFSET:
SELECT name, marks FROM Students ORDER BY marks DESC LIMIT 5 OFFSET 5;
โ This skips the first 5 rows and shows the next 5.
ID | Name | Marks |
---|---|---|
1 | Ravi | 95 |
2 | Neha | 89 |
3 | Aman | 85 |
4 | Sara | 81 |
5 | Ritu | 80 |
6 | Karan | 78 |
7 | Preeti | 76 |
๐ This helps show data in a paginated manner, like search results, product lists, etc.
๐ Write a query to show the 3rd to 5th highest scoring students (use LIMIT + OFFSET)
OFFSET
skips rows before starting to return data.LIMIT
defines how many rows to return.Next โก๏ธ: Dive into GROUP BY
to group and analyze data!
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!