简体   繁体   English

在 MySQL Java 中检索第一、第二和第三大值

[英]Retrieving the first, second and third highest values in MySQL Java

I'm using the bukkit API for minecraft and I'm curious how I would be able to retrieve the first, second, third etc;我正在为 minecraft 使用 bukkit API,我很好奇如何检索第一个、第二个、第三个等; highest value depending on what a user enters in a command part.最高值取决于用户在命令部分输入的内容。

Ignore the commandpart .忽略命令部分 I'm just wondering how I would return the first, second and third highest values etc;我只是想知道如何返回第一、第二和第三高值等; from MySQL.来自 MySQL。

What would I put in the SQL statement in order to do so?为了这样做,我会在 SQL 语句中放入什么?

Update: This is what I got so far http://pastebin.com/698AJmq6更新:这是我到目前为止得到的http://pastebin.com/698AJmq6

My structure is:我的结构是:

  • UUID用户名
  • Name姓名
  • Wins胜利
  • Winstreak连胜

How would I return the name with the highest winstreak?我将如何返回具有最高连胜纪录的名字?

You're not retrieving from PhpMyAdmin.您不是从 PhpMyAdmin 检索。 PhpMyAdmin is only a page that shows you the SQL databases. PhpMyAdmin 只是一个显示 SQL 数据库的页面。 You do not need PhpMyAdmin at all to read values from an SQL server, you're getting the values from the SQL server itself.您根本不需要 PhpMyAdmin 从 SQL 服务器读取值,而是从 SQL 服务器本身获取值。

As for the question, in that pastebin you have the following code:至于问题,在那个 pastebin 你有以下代码:

ResultSet Winstreak = p.ec.sql.querySQL("SELECT * FROM `profiles`
    ORDER BY `Winstreak` DESC LIMIT '" + e.getLine(3) + "';" );

To get the name of player with the n'th highest winstreak:要获得第 n 个最高连胜球员的姓名:

Winstreak.absolute(n); // Move cursor to a specific row
String name = Winstreak.getString("Name");

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

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