MySQL LIMIT Clause

The LIMIT clause is used to mention the number of records to be retrieved.
The LIMIT clause is useful when there is large number of records in the table. If we retrieve all the records of a table which contains thousands of records, then it can affect the performance.

Syntax for LIMIT

select * from table_name
where condition
limit number;

Consider the below table to which we will apply the LIMIT clause.

empno name age role location
001 Andrew 30 Manager India
002 Beslin 28 Business Analyst India
003 Joanna 23 Senior Developer India
004 Rayan 26 Technical Lead India

Example

select * from employee limit 3;

We can also apply where clause along with limit clause.

select * from employee
where location='India'
 limit 3;

Output

empno name age role location
001 Andrew 30 Manager India
002 Beslin 28 Business Analyst India
003 Joanna 23 Senior Developer India

Most Read