MySQL SELECT Clause with Limit and Offset relationship

SELECT Clause with Limit and Offset relationship tutorial will teach you usage of LIMIT and OFFSET in MySQL queries.

Mysql SELECT with LIMIT and OFFSET

Mysql SELECT with LIMIT and OFFSET

1. In MySQL the LIMIT used to restrict the number of rows in the result set.
2. The Limit Clause accepts one or two arguments which are offset and count.
3. The value of both the parameters can be zero or positive integers.

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.

1. LIMIT clause with one argument:

  • If we specify only one argument then the query will return only the specified number of rows.
  • The above query will return only two rows
  • If the argument’s value is 0, the result set will be empty

2.LIMIT clause with two arguments:

  • When two arguments are used in a LIMIT clause
  • First argument is called offset and it represent from which the result set will be presented.
  • The second argument specifies the maximum number of rows to be returned in the result set

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *