The MySQL LIMIT clause is used to narrow or limit, a result set to the specified number of rows.

The LIMIT clause accepts one or two arguments, one is offset and another one is count.

Offset: It is used to specify the offset of the first row to be returned.
Count: It is used to specify the maximum number of rows to be returned.


SELECT column_name(s) FROM  table_name LIMIT offset_number, count;

SELECT * FROM table_name LIMIT offset,count;

SELECT * FROM table_name LIMIT 10;

The query above will limit the result set to 10 rows.

When we will use argument in the limit clause, this argument will be used to return the maximum number of rows to be returned from the beginning of the result set.

SELECT column_name FROM table_name LIMIT count;

The above ex equivalent to this ex with the LIMIT clause that accepts two arguments.

SELECT column_name FROM table_name  LIMIT 0, count;

How to use OFFSET in the LIMIT Query.

The OFFSET value allows specifying which row to start from retrieving data.

Note: The OFFSET for the first row is 0 and not 1.

let’s suppose that if you want to retrieve data starting from the middle of the rows, then you can use the LIMIT keyword together with the OFFSET value to achieve that.

Table tblstudents



Select * from tblstudents limit 2;

The query above will limit the result set to 2rows.


id Name Roll_noClass
1 Anuj kumar 10806121
2 Sanjeev 10883327 MBA


select * from tblstudents limit 2,2;

The query above has OFFSET=2, Hence 3rd row is return and LIMIT=2, Hence only 2 record will return


id Name Roll_no Class
3 Amit 13123121 BA
4 Rahul 23424323 LLB

Recommended Tutorials for you


Anuj kumar

This is Anuj Kumar. I’m a professional web developer with 5+ years of experience. I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials. .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button