MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Limit Clause

The MySQL supports the LIMIT clause to select a limited number of rows in a result set. It accepts one or two arguments. The values of both arguments must be zero or positive integers.

Note: When you use the LIMIT clause with one argument, the maximum number of rows will be return from the beginning of the result set.

MySQL LIMIT CLAUSE Syntax

To limited the number of rows in a result set, use the following syntax:

Syntax

SELECT col1, col2, ...
FROM tablename
LIMIT offset , count;  

Parameters:

tablename: The table name from which you want to fetch the records.

LIMIT: To constrain the number of rows in a result set.

offset: The offset specifies the offset of the first row to return.

count: The count specifies the maximum number of rows to return.

MySQL LIMIT CLAUSE example to fetch first N rows

The following MySQL statement is used to limited the number of rows in a result set of select statement:

Example

SELECT firstName, lastName, address FROM tblCustomerLoan LIMIT 5;

Note:

In the above example, we are limiting the number of rows should return in a result set using LIMIT clause.

You can use MySQL Command Line Client to fetch limited number of rows in a result set using LIMIT. It will look like this: