LIMIT Clause

The LIMIT clause is used with the SELECT statement to restrict the number of rows in the result set. The Limit Clause accepts one or two arguments which are offset and count. The value of both the parameters can be zero or positive integers.

SYNTAX:

SELECT  column1,column2,...  FROM table LIMIT offset , 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.

The Limit clause accepts one or two parameters, whenever two parameters are specified, the first is the offset and the second denotes the count whereas whenever only one parameter is specified, it denotes the number of rows to be returned from the beginning of the result set

Example:

SELECT * FROM student LIMIT 3

display the top 3 rows from the student table.

Example:

SELECT * FROM student LIMIT 3,4

DIsplays 4 rows next to 3rd row from the student table.