gpt4 book ai didi

mysql - 查询最多 "upvotes"项的最佳方法

转载 作者:行者123 更新时间:2023-11-29 02:05:13 24 4
gpt4 key购买 nike

我正在努力为数据库中的某些项目添加赞成票和反对票,并按最高赞成票的顺序显示它们。这个查询会是什么样子?

我怎样才能在 SQL 中做这样的事情?

SELECT col1 col2 FROM some_table WHERE "highest number of upvotes" 

最佳答案

假设 upvotes 是您表中的一个字段,您可以使用 ORDER BY 和可选的 LIMIT:

SELECT col1, col2
FROM some_table
ORDER BY upvotes DESC
LIMIT 10

关于mysql - 查询最多 "upvotes"项的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7590867/

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