gpt4 book ai didi

php - 计算此数据集上的查询结果

转载 作者:行者123 更新时间:2023-12-01 00:14:12 26 4
gpt4 key购买 nike

使用以下查询:

$result = mysql_query(
"SELECT Stats.champion
FROM Stats, Games
WHERE Stats.game_id = Games.game_id
AND Stats.win = 1
AND Games.game_mode = 'ODIN'");

我返回了以下数据集:

Ezreal 
Garen
Pantheon
Ahri
Sion
Rammus
Nidalee
Poppy
Heimerdinger
Graves
KogMaw
Gangplank
Tristana
Fizz
Pantheon
Pantheon
Evelynn
MasterYi
Tryndamere
Leona
Vayne
Malphite
Graves
Shaco
Nidalee
Graves
Heimerdinger
Gangplank
JarvanIV
Akali

我的目标是统计每个名字的结果。我知道一个,例如“万神殿”,我可以做到:

$result = mysql_query(
"SELECT Stats.champion
FROM Stats, Games
WHERE Stats.game_id = Games.game_id
AND Stats.champion = 'Pantheon'
AND Stats.win = 1
AND Games.game_mode = 'ODIN'");

$pantheonwins = mysql_num_rows($result);
echo $pantheonwins;

这会产生正确的信息!

Pantheon 
Pantheon
Pantheon
3

既然这给了我正确的数据,那么这是获取每个名字的获胜次数,然后获取记录总数到计算机百分比的最有效方法吗?

最佳答案

尝试将您的查询更改为:

SELECT
Stats.champion,
count(Stats.champion) as myCount
FROM
Stats, Games
WHERE
Stats.game_id = Games.game_id
AND Stats.win = 1
AND Games.game_mode = 'ODIN'
GROUP BY
Stats.champion

现在,您应该在查询结果中获得计数以及 champion

关于php - 计算此数据集上的查询结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8696919/

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