我在MySQL数据库中有几个数据.在我的表中有一个名为rank的列.我要的是,当有人进入秩说,25那么结果应该显示类似的名称(+或- )的行列LIMIT,以10从表中.
例
mathew - 25
john - 26
joe - 25
stewart - 27
kelly - 24
brandon -23
magy - 22 .......etc.
Run Code Online (Sandbox Code Playgroud)
谢谢马修
您可以使用MySQL的between和limit子句:
$range = 5; // you'll be selecting around this range.
$min = $rank - $range;
$max = $rank + $range;
$limit = 10; // max number of results you want.
$query = "select * from table where rank between $min and $max limit $limit";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
258 次 |
| 最近记录: |