I’ve attempted to search but not sure I’m getting the keywords correct for this.
I want to select rows in desc order that aren’t the last 5 rows but the 5 before that!
So if I had 140 rows, I want rows 131-135.
The following ets me 136-140.
SELECT id, title, content, date FROM tbl_news ORDER BY id DESC LIMIT 5
How could I change the limit value to achieve 131-135?
Thanks.
You want to use the two parameter limit:
This will give you the first 5 rows after row 5(so rows 6, 7, 8, 9, 10) which is the 5 rows before the last 5 like you want.
Edit: Fiddle here: http://sqlfiddle.com/#!2/9113a/1
It should return id’s 4-8 as there are 12 records here.