gpt4 book ai didi

php - 从不同的列值中查找最大列值

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

我想从具有不同用户名的行中选择多个最大值。

表格:

Username | Score  
x | 50
x | 88
y | 77
y | 90
z | 101
z | 94

所以它会获取:

x = 88, y = 90, z = 101

这是我目前拥有的:

$query = mysql_query("SELECT MAX(score) AS max_score FROM table";
while ($row = mysql_fetch_array($query)) {
echo $row['max_score'];
}

我想将用户名列合并到其中,这样它就不会只回显整个表列的最大值。

最佳答案

这是你的要求

$query = mysql_query("SELECT MAX(score) AS max_score FROM table GROUP BY username";
while ($row = mysql_fetch_array($query)) {
echo $row['max_score'];
}

关于php - 从不同的列值中查找最大列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20464829/

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