简体   繁体   English

我想从数据库中的值提升和降低MYSQL

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

I want to ascend MYSQL from a value in the database. 我想从数据库中的值提升MYSQL。 Hypothetically: database with table tbl_numbers column numbers has 10 values in it 1-10. 假设:具有表tbl_numbers列号的数据库中的10个值是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. 如果这是可能的,那么什么php而不是mysql也很好。

--update!-- --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? 我给的示例很简单,我真的需要将date()与数据库中条目的日期匹配,然后从那里开始升序或降序吗? The date format is in 2010-06-18 日期格式为2010-06-18

ORDER BY numbers DESC
LIMIT 3,3

First argument for limit is (10 entries + 1) - 3; 限制的第一个参数是(10个条目+ 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. 应该做的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM