我对桌子的选择有很大的问题。我想从最高到最低向我展示,只是它在我看来是这样的NAME `POINTS`John Doe 0John Doe2 432John Doe3 64John Doe4 0John Doe5 138我想从最高到最小显示,在数据库中有超过 432 分的人只是没有显示 <?php $query = sql()->query('SELECT * FROM `PlayersData` WHERE `Points` BETWEEN 0 AND 1000 LIMIT 5');if( $query->num_rows == 0 ) { echo '<div class="nores">No records found.</div>';} else { while( $row = $query->fetch_object() ) { $row = (object) $row; ?> <div class="row"> <div><?php echo $row->SteamID ?></div> <div> <?php echo $row->Points ?> </div> </div> <?php }}?>
1 回答
慕容3067478
TA贡献1773条经验 获得超3个赞
添加一个ORDER BY, 用于DESC首先获得最高值。
SELECT * FROM `PlayersData` WHERE `Points` BETWEEN 0 AND 1000
ORDER BY Points DESC
LIMIT 5
如果数据类型不是整数,cast则在订购时:
SELECT * FROM `PlayersData` WHERE `Points` BETWEEN 0 AND 1000
ORDER BY cast(Points as integer) DESC
LIMIT 5
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报
0/150
提交
取消