MySQL SELECT LIMIT Guide

In MySQL, the SELECT statement can use the LIMIT keyword to restrict the number of results returned in a query. The syntax is as follows:

SELECT column1, column2, ...
FROM table_name
LIMIT number;

In this case, “number” refers to the number of rows to be returned. For example, if you want to return the first 5 records, you can use the following SELECT statement:

SELECT * FROM table_name
LIMIT 5;

You can also use the LIMIT keyword to specify the starting position and number of rows to return, as shown below:

SELECT * FROM table_name
LIMIT offset, count;

offset is the starting position, and count is the number of rows to return. For example, to return 3 entries starting from the 6th row, you can use the following SELECT statement:

SELECT * FROM table_name
LIMIT 5, 3;
bannerAds