Sql Select Limit in MySQL Server

Limiting result rows we use sql select limit statement for MySQL Server.
LIMIT is similiar to TOP in MS SQL Server and MS Access.
In this sql select limit tutorial we will use the sample table below for our sql select limit statement examples.

We will limit the result rows (records) in the users table with LIMIT.


Users Table; tbl_users

id Name Email Password Age
1 John Doe johndoe@j.com e56Hdf-2 34
2 Jane Doe janedoe@j.com p59Hdf-2 32
2 Gary Doe garydoe@j.com y02Tdf-2 23

SQL Select LIMIT Code

SELECT * FROM tbl_users LIMIT 2

This sql query will return top 2 rows records from users table.

Query Result
id Name Email Password Age
1 John Doe johndoe@j.com e56Hdf-2 34
2 Jane Doe janedoe@j.com p59Hdf-2 32

Note that you can also filter results by using WHERE in your sql limit queries.


SELECT limit with paging

SQL Select LIMIT PAGING Code

SELECT * FROM tbl_users LIMIT 0,5

This sql query will records starting from first records, listing 5 records from users table.


SQL SELECT TOP Code Samples