数据库架构
----------------------------------------------------------
| id | killed | killed_by | killed_uuid | killed_by_uuid |
----------------------------------------------------------
killed
和killed_by
保留实体类型。例如。 “玩家”,“环境”,“生物”。没有具体细节。
killed_uuid
和killed_by_uuid
是玩家参与杀戮的用户ID。
此表保存在我的游戏服务器上发生的杀戮。每个kill都存储在一个单独的行中,因此每个玩家都没有总计。
我想为每个用户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
)
答案 0 :(得分:4)
select killer, count(killer) as total_kills
from kills
where killed='player' and killed_by not in (<list of environment ids>)
group by killer
order by total_kills desc, killer
答案 1 :(得分:0)
SELECT COUNT(*) FROM KILLS WHERE KILLED=? AND KILLED_BY NOT IN (?, ?, ?, ?, ?, ...)