tags:

views:

33

answers:

2

I want to ascend MYSQL from a value in the database. Hypothetically: database with table tbl_numbers column numbers has 10 values in it 1-10. I want to:

order by numbers desc {from 8} LIMIT 3

it would show

8
7
6

instead of:

order by numbers desc LIMIT 3 

10
9
8

If this is possible what php and not mysql that's good too.

--update!--

The example I gave was way to easy, I really need to match the date() with the dates of the entry's in the database and start the asend or decend from there any ideas? The date format is in 2010-06-18

A: 

Something along the lines of

ORDER BY (numbers < 8) DESC, numbers DESC LIMIT 3

should do the job.

Pekka
+4  A: 
ORDER BY numbers DESC
LIMIT 3,3

First argument for limit is (10 entries + 1) - 3; second argument is the number of records to return

Alternatively:

WHERE numbers <= 8
ORDER BY numbers DESC
LIMIT 3
Mark Baker
you mean (10 entries + 1) - 3, right? This is how far from the start of the result to start displaying?
chustar
@chustar I stand corrected
Mark Baker
Indeed. should be as easily implementable with dates (`WHERE datecol <= <date> ORDER BY datecol DESC LIMIT 3`)
Wrikken