gpt4 book ai didi

mysql - 从 MySQL 的表中选择前 3 个值

转载 作者:行者123 更新时间:2023-11-29 05:03:16 25 4
gpt4 key购买 nike

我有一张 table newscount其中有三列id , postid , count 。数据示例如下:

id | postid | count 
-------------------
2 | 6 | 14
3 | 8 | 25
4 | 9 | 9
5 | 10 | 16
6 | 11 | 15

我想选择3 postid其中有最大计数。在上面的示例中,它应显示 8、10、11。

最佳答案

使用 ORDER BY 降序排列 LIMIT(选择前 3 个)。

SELECT *
FROM newscount
ORDER BY count DESC LIMIT 3

关于mysql - 从 MySQL 的表中选择前 3 个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53756115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com