MySQL Limit and Offset Clause

MySQL Limit:

The LIMIT clause is used in the SELECT statement to constrain the number of rows in a result set. The LIMIT clause accepts one or two arguments. The values of both arguments must be zero or positive integers.

Syntax of MySQL Limit:

SELECT * FROM <table_name> LIMIT [Number to Limit By];

Example of MySQL Limit:

(1) MySQL LIMIT Clause set to 4:

mysql Limit set to 4

(2) MySQL LIMIT Clause use along with ORDER BY Clause:

MySQL Limit Clause use along with Order By Clause

(3) MySQL LIMIT Clause use along with WHERE Clause:

MySQL LIMIT Clause use along with WHERE Clause

MySQL Offset:

The offset specifies the offset of the first row to return. The offset of the first row is 0, not 1.

Syntax of MySQL Offset:

SELECT * FROM <table_name>
LIMIT 4 OFFSET [Number of rows to skip];

Example of MySQL Limit and Offset Clause:

(1) MySQL LIMIT Clause set to 4 and OFFSET Clause to 0:

MySQL LIMIT Clause set to 4 and OFFSET Clause to 0

(2) MySQL LIMIT Clause set to 4 and OFFSET Clause to 1:

MySQL LIMIT Clause set to 4 and OFFSET Clause to 1

(3) MySQL LIMIT Clause set to 4 and OFFSET Clause to 7:

MySQL LIMIT Clause set to 4 and OFFSET Clause to 7

MySQL Insert Query (Single Row and Multiple Row)
MySQL Select Query with Where Clause
MySQL Logical Operators
MySQL IN Operator
MySQL LIKE Operator
MySQL Between and Not Between Operators
MySQL Order By and Distinct Clause
MySQL– Wikipedia

Comments (No)

Leave a Reply