我正在制作一个游戏服务器的排行榜,并希望有一些东西。
我在MySQL中有一张表,看起来像这样 (还有其他列存在,但我想忽略)
有没有办法在steam_id_64每行与相同的值结合起来,但是player_name显示最后使用的蒸汽名称(或蒸汽当前的),并且可以隐藏steam_id_64为BOT的行吗?
如果这有帮助,我有php5。 感谢您的帮助。
I am making a leaderboard for a game server and would like a hand with something.
I have a table in MySQL that looks like this (There are other columns that exist but I want to ignore)
Is there a way to combine each row with the same value in steam_id_64, but with player_name show the last used steam name (Or current from steam) and is it possible to hide the row where steam_id_64 is BOT?
I have php5 if that is helpful. Thank you for the help.
最满意答案
你必须使用sum()函数总结不同的列。 为了避免这些bot条目,你可以使用条件来测试player_name不是BOT
select player_name, sum(kills) as kills, sum(deaths) as deaths, sum(assists) as assists, sum(head_shots) as headshots, sum(team_kills) as team_kills, sum(assists_team_attack) as assist_team_attack, sum(damage) as damage, sum(hits) as hits, sum(shots) as shots, sum(last_alive) as last_alive group by steam_id_64 where steam_id_64 != "BOT"为了方便以后的处理,我为每个sum()添加了“... as field_name”。
如果有遗漏,请尝试此操作并优化您的问题。
You have to sum up the different columns using sum() function. To avoid those bot entries you can use a condition to test for player_name is not BOT
select player_name, sum(kills) as kills, sum(deaths) as deaths, sum(assists) as assists, sum(head_shots) as headshots, sum(team_kills) as team_kills, sum(assists_team_attack) as assist_team_attack, sum(damage) as damage, sum(hits) as hits, sum(shots) as shots, sum(last_alive) as last_alive group by steam_id_64 where steam_id_64 != "BOT"To make later handling convenient I have added "... as field_name" to each sum().
Please try this and refine your question if something is missing.
更多推荐
发布评论