Use of Limit with Offset in MySQL

0
68
MySQL

Here is the example of limit with offset in MySQL

If you want to select top 10 records from table then you can use limit in your sql query.

$sql = “SELECT * FROM table_name LIMIT 10”;

Use of OFFSET

This following SQL query returns only 10 records starting from record 21 Offset “:

$sql = “SELECT * FROM table_name LIMIT 10 OFFSET 20”;

You can also make it shorter for same result:

$sql = “SELECT * FROM table_name LIMIT 20, 10”;

Important: the numbers are reversed when using comma.

LEAVE A REPLY

Please enter your comment!
Please enter your name here