mySQL计算表中每个ID的行数
数据库架构
----------------------------------------------------------
| id | killed | killed_by | killed_uuid | killed_by_uuid |
----------------------------------------------------------
killed
和 killed_by
保存实体类型。例如。 “玩家”、“环境”、“生物”。没有具体细节。
killed_uuid
和 killed_by_uuid
是玩家参与杀戮时的用户 ID。
该表保存了我的游戏服务器上发生的击杀事件。每次击杀都存储在单独的行中,因此每个玩家没有总计。
我想为每个用户 ID 创建总计并根据它们创建排行榜。所以基本上,计算每个单独的 UserID 的行数。
我尝试使用
select killed_by_uuid, count(id)
from kills
where killed='999' AND killed_by='999'
group by killed_by_uuid
order by count(id) desc
999
作为属于玩家实体的 ID,而不是实际的 USERID。但我得到的只是一个结果集:
Array
(
[0] => c676680f-98cb-4893-b1ba-ab5ab59fc272
[killed_by_uuid] => c676680f-98cb-4893-b1ba-ab5ab59fc272
[1] => 15
[count(id)] => 15
)
Database schema
----------------------------------------------------------
| id | killed | killed_by | killed_uuid | killed_by_uuid |
----------------------------------------------------------
killed
and killed_by
hold the entity type. eg. "Player", "Environment", "Creature". No specifics.
killed_uuid
and killed_by_uuid
are the userID's if a player is involved in the kill.
This table holds kills that happens on my game server. Each kill is stored in a separate row so there are no totals for each player.
I want to create the totals for each userID and create a leaderboard from them. So basically, count the rows that for each separate UserID.
I have tried using
select killed_by_uuid, count(id)
from kills
where killed='999' AND killed_by='999'
group by killed_by_uuid
order by count(id) desc
999
being the ID that belongs to a player entity kill NOT an actual USERID. But all I get is a single result set:
Array
(
[0] => c676680f-98cb-4893-b1ba-ab5ab59fc272
[killed_by_uuid] => c676680f-98cb-4893-b1ba-ab5ab59fc272
[1] => 15
[count(id)] => 15
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)