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.
To limited the number of rows in a result set, use the following syntax:
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.
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: