When you only want a certain number of records to be loaded in the grid, you can achieve this without LIMIT. You need to have or create a specific column though to be able to do this.
Example 1, when you have an auto_increment column named ID, and you only want the
FIRST 3 records created to be displayed:
SELECT *
FROM table tab
WHERE 3 > ( select count(*)
from table tab2
where tab2.id < tab.id
)
Example, when you have an auto_increment column named ID, and you only want the
LAST 3 records created to be displayed:
SELECT *
FROM table tab
WHERE 3 > ( select count(1)
from table tab2
where tab2.id > tab.id
)
Change “3” to change the number of records to be displayed.
If you need a specific range, you need 2 of these statements in the WHERE clause (using AND operator).
You can also achieve this when you have only a datetime_created column that is unique in the table
Note: when you don’t specify an ORDER BY clause in the sql, Mysql orders your rows by default based on creation of the rows. It does not use any of your columns for this.