Reputation: 473
My issue here is that i want to populate all the records except latest 100 records in the database. What could be the best approach to accomplish this?
Upvotes: 1
Views: 356
Reputation: 254916
SELECT *
FROM Table
WHERE ID < (SELECT ID
FROM Table
ORDER BY ID DESC
LIMIT 99, 1)
Upvotes: 0
Reputation:
Try using limit cause
SELECT *
FROM Table
order by id desc
limit 101 , totalrecords
Here id is auto increment field of your table
Upvotes: 2
Reputation: 166396
How about something like
SELECT t.*
FROM Table t LEFT JOIN
(
SELECT ID
FROM Table
ORDER BY ID DESC
LIMIT 100
) top100 ON t.ID = top100.ID
WHERE top100.ID IS NULL
Where ID
would be the column to identify the order (latest) and Table
from where you wish to select
Upvotes: 0