views:

33

answers:

1

This is a follow on from another question i made

I have this query that counts all the records up to a certain point i choose whcih works fine

SELECT count(*)FROM news WHERE id < 18

this query gives me a count of 7

I am now having problems with the offset which would be the result of the above query

I tried using this query

SELECT * FROM `news` ORDER BY id DESC LIMIT 7,1

but i get id number 13 instead of 18

The ids i should have is 2, 7, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 23

I have tried using order by id desc in the count query which does give a different result but still wrong id displayed

+1  A: 

I dont see a problem here: You order the result by id DESC which means your result is ordered by other way around and 8th value(0..7) is 13.

Try sorting it by ASC then it will give you 18

Imre L
I managed to fix it by going the other way and looking for freater than then just minus 1 off the result to get me the right id
AdRock