统计该数据集上的查询结果
使用以下查询:
$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
那么,既然这给了我正确的数据,那么这是获取每个名字的获胜计数,然后获取计算机百分比的记录总数的最有效方法吗?
with the following query:
$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'");
I am returned the following dataset:
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
My goal is to count the result for each name. I know for one, for example "Pantheon", I can do:
$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;
This results with the correct information!
Pantheon
Pantheon
Pantheon
3
So since this gives me the correct data, is this the most efficient way to get the win count for each individual name, then get a total number of records to computer percents?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将您的查询更改为:
现在,您应该在查询结果中获得计数以及
champion
。Try changing your query to this:
Now, you should get the count along with the
champion
in the query result.怎么样:
会返回,
但如果你想得到这样的结果:
那么你应该使用这个:
how about this:
will return
but if you want to have results like this:
then you should used this: