mysql - Selecting the last 5 rows in a table except the last row -
I wanted to select the last 5 entries of the table except the last entry of the table. I have a table that maintains the details of the week of the year. So to get a report of the last 5 weeks, I have to remove the data from the table. I do not want this week's statistics, except for this week's data, how to select data for the last five weeks
< P> Give ID the primary key of your table, which is auto-increment. You can use the following query.
SELECT * FROM (SELECT * FROM TABLE ORDER ID DESC LIMIT 6) Sub-order ID ASC limit 5;
Comments
Post a Comment