gpt4 book ai didi

mysql - 对两列中的值进行排序并将顺序位置插入到mysql中的另一列中

转载 作者:行者123 更新时间:2023-11-29 06:07:57 25 4
gpt4 key购买 nike

我有一个关于体育赛事的数据库,其中包含:
*用户名
*用户在该事件中获得的积分数
*用户完成跟踪的时间 (HH:MM:SS)。

我怎样才能先按编号对它们进行排序?点数,如果两个用户的点数相同,则按时间计算(越短越好);然后将位置插入到行中?

我有这样的数据库:

ID    No. of Points   Time     Place------------------------------------1        15          00:56:002        13          00:55:153        17          01:00:004        17          00:57:005        19          00:52:15

我需要把它放在地方:

ID    No. of Points   Time     Place------------------------------------1        15          00:56:00   42        13          00:55:15   53        17          01:00:00   34        17          00:57:00   25        19          00:52:15   1

我希望,你明白这一点。抱歉英语不好。

最好的问候,

最佳答案

You can do this with update statement as follows. 

SET @placeValue:=0;

UPDATE [Table Name] SET Place=@placeValue:=@placeValue+1 ORDER BY
[Amount of Points] DESC,Time ASC

关于mysql - 对两列中的值进行排序并将顺序位置插入到mysql中的另一列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40187794/

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