开发者

I want to ascend and decend MYSQL from a value in the database

开发者 https://www.devze.com 2023-01-03 19:41 出处:网络
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 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开发者_StackOverflow社区} 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


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


Something along the lines of

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

should do the job.

0

精彩评论

暂无评论...
验证码 换一张
取 消