How to make a query, searching for data from the given ID?
For example, my table has 1mil records, I want to determine in a foreach the search of the data from the 300 record.
How to make a query, searching for data from the given ID?
For example, my table has 1mil records, I want to determine in a foreach the search of the data from the 300 record.
So I understand you'd like to get records in a range, you could be using OFFSET
and LIMIT
SELECT coluna FROM tabela ORDER BY id LIMIT 10 OFFSET 10;
In this case, you can use OFFSET
to determine what would be the start id and LIMIT
to determine how many records you want.
The above example will return the id's from 11 to 20.
I hope I have helped.
Reference: